Mouse jumping around the screen

Ask general questions here.
jason.smith
Posts: 2
Joined: Thu Feb 09, 2017 11:09 pm

Mouse jumping around the screen

Post by jason.smith » Fri Feb 10, 2017 4:31 pm

I have Windows 7 Enterprise 64 bit SP1 fully updated with 8GB of RAM.

I am trying to do just a very basic screen recording with IE.

I start the recording, have it open a page on IE and I am just logging into a site, clicking buttons, clicking on checkboxes, filling out forms. That's really about it, nothing fancy at all.

I have even slowed down, and even tried speeding up the mouse movement speed and mouse click speed. Slowing it way down seem to help for the most part.

But what is happening is when I am done, and I run a playback it will run pretty good for the most part, but there are sometimes when the mouse will jump to the top left corner of the screen and click. Then it will stop or mess up the rest of the sequence.

I have tried a bunch of different things so far such as just running through the whole thing just clicking on everything and letting it record, which 99% of the time that always fails. Either it is going to fast and get ahead of itself and fails, or if I slow it down the mouse will jump to the top left of the screen and then fail. I have also tried to put in a bunch of validations to make sure the page loads and finds what it needs to click on. That seems to make it a little better but I still get the mouse jumping around. The thing that seems to work is to slow the mouse down and putting in validation and sometimes even some extra clicks into dead space on the page to just slow the mouse down some more.. But I am still stuck with the mouse jumping to the top left of the screen.

I have looked on here and online and the only thing I could find was about not turning cache on. I tired that and it doesn't change anything either.

I'm just surprised for just a simple recording of a website and a few clicks, buttons and forms that I can get this to work.

Thanks
Jason

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Mouse jumping around the screen

Post by Stub » Mon Feb 13, 2017 9:32 am

I wonder if the mouse click in the recording is relative to a screen element e.g. (10;10). And if that element doesn't always exist as expected or somehow has a (0;0) screen location because it's sort of hidden, maybe that's why the mouse click jumps to the top left of the screen?

Can you hone it down to a particular step? Introduce a few 'wait for element to exist' steps into the recording in case it's too quick and the screen element you need is 'between' states when the mouse click comes along?

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Mouse jumping around the screen

Post by krstcs » Mon Feb 13, 2017 5:08 pm

You are human, and you are 'programmed' to wait for things to finish loading before you do things. The computer isn't. Ranorex will go as fast as it possibly can, which means it will go too fast if you don't tell it to wait for things some times.

When you're recording, Ranorex doesn't record the waits, it just records the action events. So when it runs the recording, it won't have the waits that you, as a human, automatically did.

I don't use recordings anymore, I've found it takes more time to correct them for issues like this than it does to just make it the way I want in the first place.

There are a couple of things you can do. The easiest is to add " and @state='complete'" to the /dom RanoreXPath, like this:

Code: Select all

/dom[@domain='www.myDomain.com' and @state='complete']
This will tell Ranorex to wait for the top-level domain element to be completely loaded before it considers the element as found. This may not work for some pages with scripts that load more parts after the initial load, but it does for most webpages.

Another thing you can do is add a WaitForExists() right before any action that you are having problems with. But, if the element is available but not really ready yet, you can still have issues like you are having. Ranorex will ONLY wait until the element exists though, so it doesn't slow down the test.

The final thing is to add hard delays into the script. This is the least desirable because Ranorex will wait the full timeout of the delay before it continues. Sometimes, however, it is the only thing that works all the time.
Shortcuts usually aren't...

jason.smith
Posts: 2
Joined: Thu Feb 09, 2017 11:09 pm

Re: Mouse jumping around the screen

Post by jason.smith » Mon Feb 13, 2017 11:36 pm

krstcs wrote:You are human, and you are 'programmed' to wait for things to finish loading before you do things. The computer isn't. Ranorex will go as fast as it possibly can, which means it will go too fast if you don't tell it to wait for things some times.

When you're recording, Ranorex doesn't record the waits, it just records the action events. So when it runs the recording, it won't have the waits that you, as a human, automatically did.

I don't use recordings anymore, I've found it takes more time to correct them for issues like this than it does to just make it the way I want in the first place.

There are a couple of things you can do. The easiest is to add " and @state='complete'" to the /dom RanoreXPath, like this: This will tell Ranorex to wait for the top-level domain element to be completely loaded before it considers the element as found. This may not work for some pages with scripts that load more parts after the initial load, but it does for most webpages.

Another thing you can do is add a WaitForExists() right before any action that you are having problems with. But, if the element is available but not really ready yet, you can still have issues like you are having. Ranorex will ONLY wait until the element exists though, so it doesn't slow down the test.

The final thing is to add hard delays into the script. This is the least desirable because Ranorex will wait the full timeout of the delay before it continues. Sometimes, however, it is the only thing that works all the time.


krstcs Thank you for the reply. I would love to try the first one with adding that path to the DOM but I am extremely new to Ranorex and I have no idea where to even go to do that. I tried reading the manual page but I still am a bit confused. Any help would be greatly appreciated.

It doesn't seem to be completely consistent. But I will get a few pages (and it completely varies) where the mouse starts moving to where the button is and then just as the page finishes loading the mouse jumps all the way to the top left, and the whole thing stops. So I certainly see what you mean and adding a page load, wait option would help.. I hope.

Jason

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Mouse jumping around the screen

Post by odklizec » Tue Feb 14, 2017 11:42 am

Hi Jason,

You just have to add the suggested attribute:
and @state='complete'
at the end of DOM xpath (in repository window). DOM element is the top level element of any web page you are automating. So for example, for www.ranorex.com it would be /dom[@domain='www.ranorex.com']

Also, I would strongly recommend you to watch all screencasts, available here (especially Ranorex xpath related):
http://www.ranorex.com/support/screencasts.html

And also read thoroughly (and understand) these Ranorex user guide chapters:
http://www.ranorex.com/support/user-gui ... x-spy.html
http://www.ranorex.com/support/user-gui ... xpath.html

Understanding Ranorex xpaths and how to work with them is critical for successful Ranorex usage.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Mouse jumping around the screen

Post by Fergal » Tue Feb 14, 2017 12:00 pm

krstcs wrote:...I don't use recordings anymore....
Interesting, do you do everything in code modules? Does it take you longer to create the initial tests?

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Mouse jumping around the screen

Post by krstcs » Tue Feb 14, 2017 4:51 pm

Sorry Fergal, I should have said I don't use the RECORD functionality anymore. I still use Recording Modules, but I create all the actions manually. I do use a lot of User Code Modules as well, but I was a C# developer before I was a Ranorex user.

In addition, I keep my modules VERY VERY small. Usually each one does one thing only, one atomic action. I have modules called "Click_OK" and "Enter_Password" or "Enter_Username" as opposed to "Login". I do this because it makes it much easier to reuse the modules in other places so I actually end up using Test Cases or Module Groups for the sequence of events and I can just drag-and-drop modules where I need them.

I also have very dynamic test suites. I have test cases nested under 5-6 other nested cases, each with a SQL data connector that is unique for that case and the SQL statement is rewritten at runtime in order to make the case run or not depending on the parent case's data.

So, I only really have 2 suites. One tests ALL the functionality of our Point-of-Sale system and the other tests ALL the functionality of our Custom Design Center. They test different things in those systems depending on the data sets that are passed into them.

This dynamic testing is not something I would recommend to new users, but once you get it going it is so much easier to manage and add new test sets to that it is well worth it.
Shortcuts usually aren't...

Fergal
Certified Professional
Certified Professional
Posts: 455
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Mouse jumping around the screen

Post by Fergal » Mon Feb 20, 2017 12:10 pm

Thanks for those very helpful details krstcs, it sounds like you have a very comprehensive setup.