Page 1 of 1
How to set different timeouts for same element
Posted: Mon Nov 30, 2015 1:08 pm
by bygones
Hi,
I have an element that I like to set different timeouts in different tests. But when I add the element to my test suite via the repository and set the timeout, all same elements in all other test suites are also updated with that timeout.
Is it possible to set the timeout individually ?
Thanks
I'm using Ranorex 5.4.3.26106
Re: How to set different timeouts for same element
Posted: Thu Dec 03, 2015 1:24 pm
by Support Team
Hi bygones,
The Searchtimeout is stored directly in the RepositoryItem.
In order to set the timeout individually per item you need to write a short userCode action. This action should contain the following lines of code
public void ModifySearchTimeOut(Ranorex.Core.Repository.RepoItemInfo RepositoryObject)
{
Duration oldTimeout;
Duration newTimeout=2000;
oldTimeout = RepositoryObject.SearchTimeout; //Save defaultTimeout
RepositoryObject.SearchTimeout=newTimeout; //Set new Timeout
//Do some things
RepositoryObject.SearchTimeout=oldTimeout; //Restore defaultTimeout
}
Now you can call this action within your recording module. As parameter you need to select the corresponding RepositoryItem
For example:
ActionTable_UserCode_SetTimeout.png
Hope that helps.
Regards,
Markus (S)
Re: How to set different timeouts for same element
Posted: Fri Dec 04, 2015 2:49 pm
by krstcs
Or, you could do the easy thing:
Create multiple copies of the repo item and change the timeouts of each to what you need. Just make sure to rename the items so you know which one you are using.
You can have as many repo items as you want all pointing to the same SUT element.
Re: How to set different timeouts for same element
Posted: Sat Dec 05, 2015 8:47 am
by bygones
Thanks for the answers - I think krstcs answer fits my use case best.
Re: How to set different timeouts for same element
Posted: Wed Dec 16, 2015 4:13 am
by jasoncleo
Hi ByGones,
Depending on whether you write your tests via Code Modules or the Recording Modules.
Recording Modules
If you're using the Recording Modules, then perhaps krstcs' suggestion is easiest. However the potential issue is that it'll increase your maintenance overhead down the track if the developers modify the UI. Instead of having one of each UI item to change, you now have several instances of some UI elements that need to be looked up and modified, possibly across different UI repositories.
The other thing to remember, is that in your UI repository, the timeout is cumulative as you move through the Rooted folders to the UI element.
Ultimately though, I don't have a better suggestion.
Code Modules
This offers you the greatest flexibility and there are a number of ways of tacking this:
- 1. You can use the .Exists() method of the UI element Info, and pass your own duration to it.
2. You could even write your own static method which takes a RXPath and timespan. (RXPath is obtained from the AbsolutePath property of the UI element Info). The benefit of this is you could also add in checks for visibility, or enabled, and that makes just a single call. You can also decide whether you have it just return a bool or throw exceptions based on your choice of failure handling.
Re: How to set different timeouts for same element
Posted: Fri Dec 18, 2015 10:28 am
by bygones
thanks for the posts - I will consider doing this via Code Modules