Ranorex is very easy to validate the existence of an object. How can Ranorex validate a non-exist of an object? I think it has to be done through the user code, correct?
For example, here is the existence validation “Validate.Exists(repo.appinterface.item1)"
How to validate the non-exist of this object?
Thanks,
how to validate a non-exist of one object
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: how to validate a non-exist of one object
In the current version you can check non-exist elements as follow:
Gabor
Ranorex Support Team
try { Validate.Exists(repo.Gen2Interface.Gen2Dom.ImportSettings); } catch (RanorexException e) { Report.Error("Element does not exist."); }In the upcoming V2.2 you will be able to use following code:
Validate.Exists(repo.Gen2Interface.Gen2Dom.ImportSettingsInfo);Kind regards,
Gabor
Ranorex Support Team
Re: how to validate a non-exist of one object
I've used one of the Find() methods to do this:
You can then use Exists() like any other boolean, so you can say if (!Exists(...)).
I've further used the Exists() function to get ERanorex to wait for a progress bar window to go away, by using it to control a while loop that just does a Delay() at each iteration
Code: Select all
/// <summary>
/// The function returns the (first) Element found as an Object, or NULL.
/// </summary>
public static Object GetObject(RxPath aRxPath, Ranorex.Duration aTimeout)
{
System.Collections.Generic.IList<Element> lList = Host.Local.Find(aRxPath, aTimeout);
if (lList.Count > 0) {
return lList[0];
} else {
return null;
}
}
public static bool Exists(RxPath aRxPath, Ranorex.Duration aTimeout)
{
return GetObject(aRxPath, aTimeout) != null;
}
I've further used the Exists() function to get ERanorex to wait for a progress bar window to go away, by using it to control a while loop that just does a Delay() at each iteration
David Allsopp,
Test Automation Engineer, Mitrefinch Ltd.
Test Automation Engineer, Mitrefinch Ltd.
Re: how to validate a non-exist of one object
Hi,
Could somebody give a example code, how to verify e.g. progress bar is shown and do this "while-delay()-loop" until progress bar is not shown anymore?
If I verify with Valitade.NotExists method, it will throw exception?
Could somebody give a example code, how to verify e.g. progress bar is shown and do this "while-delay()-loop" until progress bar is not shown anymore?
If I verify with Valitade.NotExists method, it will throw exception?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: how to validate a non-exist of one object
Hi!
use code like:
Peter
Ranorex Support Team
First you have to find out which value you want to obtain. Open Spy and track your progress bar. Now start your actions with the progress bar as you would do it with your test. If your test finished update SPY elements and take a look on Overview/General which property of item(progress bar) has changed. After this evaluationSanMan wrote:Could somebody give a example code, how to verify e.g. progress bar is shown and do this "while-delay()-loop" until progress bar is not shown anymore?
If I verify with Valitade.NotExists method, it will throw exception?
use code like:
while(YourProgressBar.Visbile == true) //instead of Visible you can use Enabled/Valid { //do some action }Regards,
Peter
Ranorex Support Team