Mouse mover to left hand corner of form

Ask general questions here.
brentmclauclan
Certified Professional
Certified Professional
Posts: 23
Joined: Wed Jun 25, 2014 11:59 am

Mouse mover to left hand corner of form

Post by brentmclauclan » Thu Jul 17, 2014 5:58 pm

Hi there.

At times when I try a mouse click on a web page's button, the mouse pointer icon moves quickly to the top left corner and the Mouse Click on the Button does not occur. Adding a Delay action just prior the Button Click action seems to fix the issue and the Button Click occurs ok.

Just wondering why?

Brent

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

Re: Mouse mover to left hand corner of form

Post by krstcs » Thu Jul 17, 2014 6:56 pm

Web pages take time to load completely. Until they are fully loaded, Ranorex may not be able to find elements.

In your case, the button you are trying to click on exists in code (or Ranorex would tell you it couldn't find it) but it hasn't been rendered completely at the time the Ranorex is attempting to click it.

You should always wait for the page to finish loading before you attempt any action on any of the elements of the page.

I have my main web document (the '/dom' object in the repo) set to always look for a state='complete'. For example:

Code: Select all

/dom[@domain=$domain and @state='complete']
This will force Ranorex to not find the web page until it sets the state to complete.


EDIT TO ADD:
Some sites (including the one I work on) will show 'complete' and then load more scripts, sometimes a couple of times. While the RXPath above will help with that, it won't solve it. I have a special module that I put everywhere in my test that would require waiting for the page to reload. I call it "_WAIT_FOR_PAGE_RELOAD" and it actually has 3 iterations of WAIT_FOR_NOT_EXIST(DOM_STILL_LOADING) and DELAY(500ms) so I make sure that I catch all of the possible script issues. The DOM_STILL_LOADING path looks the same as above, but changes the "=" in the "@state='complete'" to a "!=" (not equals) so I can wait for the loading to no longer exist.

I would add that this only works if you have set up your test modules to be very atomic/small and modular. If you haven't done that you would need to add the waits in the modules in every place you need to wait, and then change it in every place when you need to make changes. If you make it more modular, you will have to add the recording modules in several places, but you only have to edit that one module if you need to make changes.
Shortcuts usually aren't...