UserCode line not advancing test script

Ask general questions here.
charles7926
Posts: 3
Joined: Tue Jun 03, 2014 7:34 pm

UserCode line not advancing test script

Post by charles7926 » Thu Apr 30, 2015 1:39 pm

In our application we have a screen that pops up the first time a user adds a new client each day. The screen just says "Hello, have a nice day". It does that for each unique user. I am trying to find a way to work around it in my script. It is not a popup, but a normal screen, and so the popupwatcher didnt work for me (I did try it). I wrote a usercode module that just does an if statement.

Code: Select all

IF (rep.myapp.welcomemessage.exists()) rep.myapp.welcomemessage.buttonok.click();
My problem though, is that when I run the test, the usercode successfully runs, but the test wont advance to the next line. It just sits there waiting for the repository object from the previous line to display (the line previous to the usercode).

Any ideas on what I may be doing wrong? Do i have to include some line in my usercode to make the runner advance?

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

Re: UserCode line not advancing test script

Post by krstcs » Thu Apr 30, 2015 1:47 pm

A couple of things to understand:

1. The Ranorex progress display in the bottom right corner of the screen only displays the LAST Report.Log entry that was executed. If it isn't updating then your code is stuck somewhere between the Report.Log it is displaying and the next one, most likely on the search.

2. The Exists() method will still try to find the object using the 'Effective Timeout' of the element, which is the cumulative timeouts of the element and all parent elements in the repository. So if your element has 3 parents and all 4 of the elements have a 30 sec timeout, then the Effective Timeout for that element is 2 min.

My suggestion would be to add a Report.Log() line before each user-code line that might be causing the issue. The last Report line that runs is the one right before the code with the issue.

In your case it could look like this:

Code: Select all

Report.Log(ReportLevel.Info, "USER", "Checking for welcome message and clicking OK if it exists.");
if (rep.myapp.welcomemessage.exists()) rep.myapp.welcomemessage.buttonok.click();
You might also want to change the if to a multi-line code block so you can put another Report.Log line inside it with the click action, just in case the issue is with clicking the button.
Shortcuts usually aren't...

charles7926
Posts: 3
Joined: Tue Jun 03, 2014 7:34 pm

Re: UserCode line not advancing test script

Post by charles7926 » Thu Apr 30, 2015 2:32 pm

@krstcs - awesome. Thank you, that was a huge help. It turned out to be a pathing problem. For whatever reason the button on that page was using a UIA reference and it was taking forever to look for it. I guess I had never actually given it a chance to reach the full timeout. It does seem now though that every time the script runs if the welcome page does not come up I am forced to wait for the timeout to occur. Is there a way to chagne the timeout length just for this function?

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

Re: UserCode line not advancing test script

Post by krstcs » Thu Apr 30, 2015 3:36 pm

Yes, Exists() has a couple of signatures.

Exists() - Waits for the repo item's timeout.

Exists(Duration) - Takes a duration and only waits that long - This is the one you probably want.

Exist<T>(out T) and Exists<T>(Duration, out T) are the same, but return an object of type 'T' (generics) as an output parameter. You probably won't need this except on very special cases.
Shortcuts usually aren't...