Data-driven-test mit exception in the first iteration

Experiences, small talk, and other automation gossip.
Posts: 121
Joined: Tue Jun 03, 2014 10:15 am
Location: Hamburg, Germany

Data-driven-test mit exception in the first iteration

Post by BCTest » Wed Jun 04, 2014 8:02 am


I'm absolutly sure there is already a solution for my question in this forum but I can't find it.
We have a special problem with a data-driven-test handling an exception in the first iteration. Just to explain the behaviour the iteration looks like this:

- Iteration
+ Dialog 1 (this dialog is not displayed in the first iteration)
+ Dialog 2
+ Dialog 3

We decided to add some user code like shown in the Code Examples (.../support/user-guide-20/test-automation-code-examples.html#c3203 - sadly I cannot post URL's) to validate if this particular repository item exists or not:

Code: Select all

// Validate 'Enabled' attribute of button 'Delete'  
Works great but the tests waits for 30 seconds to continue (without fail). So we tried to set a SearchTimeOut for 100 milliseconds like written in the API (.../Documentation/Ranorex/html/P_Ranorex_Core_Repository_RepoItemInfo_SearchTimeout.htm):

Code: Select all

public Duration SearchTimeout { get; set; }
Here is our code-snippet:

Code: Select all

repo.Positionserfassung.ButtonNeuInfo.SearchTimeout = 100;

Report.Info("Taste 'F2 - Neu' fehlt beim ersten Durchlauf - Timeout: " + repo.Positionserfassung.ButtonNeuInfo.SearchTimeout.ToString());
if (Validate.Exists(repo.Positionserfassung.ButtonNeu, "Prüfe Existenz von Taste '{0}'", false)) repo.Positionserfassung.ButtonNeu.Click();
Looks like we are doing something wrong because Ranorex still waits for 30 seconds:
So our question is:
How can we minimize the SearchTimeout only for this repository item?

Perhaps our solution is not the best, maybe there is a much easier way to solve this test-design? And probably without warning?
You do not have the required permissions to view the files attached to this post.

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

Re: Data-driven-test mit exception in the first iteration

Post by krstcs » Thu Jun 05, 2014 3:03 pm

First, unless someone is going to be sitting watching the test run, or manually interacting during the test run, the timeouts being 30 seconds shouldn't be a problem. Functional UI test automation does not automatically make the tests take 0 (zero) time. There will be pauses and waits while Ranorex tries to find things. Dont' worry about those. Also, you have to remember that Ranorex will search for the element for the COMBINED timeout of ALL parent elements added to the timeout of the element in question. So for your button it would search, by defualt, for 1 (one) minute. If you want to shorten that, you will need to shorten all timeouts of all parent elements as well as the element in question.

Second, I would suggest that you use the Exists() method of the element's RepoItemInfo object. So, for your button, you should try something like the following:

Code: Select all

if (repo.Positionserfassung.ButtonNeuInfo.Exists()) repo.Positionserfassung.ButtonNeu.Click(); 
The Validate class should only be used for Validation of expected results during test runs as it produces RanorexExceptions if it fails.
Shortcuts usually aren't...