I'm using Ranorex 9.3
What I'm trying to accomplish is this:
the first time my script runs on a new day, after a particular OK button is pressed/clicked, it encounters a Yes button that gets pressed/clicked followed by several other actions. if the script runs again on the same day and the same OK button is clicked, the Yes button will not even materialize in the application. So, I converted all the "bunch of other stuff" (as indicated in the psuedo-code below) into a code module but I'm having a hard time figuring out how to create the if statement below. the validate.Exists action is a void method and I need some sort of action that will check for the button and return true if it exists and false if it doesn't without failing/stopping the script at this point. I also want to limit the duration for finding the Yesbutton to no more than 5 seconds. Any suggestions?
OKbutton.PerformClick();
if (Yesbutton.exists)
{
Yesbutton.PerformClick();
<do a bunch of other stuff>
}
need valid exists condition logic for IF statement
Re: need valid exists condition logic for IF statement
Hi,
I think this should be an easy task. Here is an example code, where elementToCheck is assigned repo element...
BTW, I would recommend to use standard Click action or Move/Click sequence, instead of PerformClick, which may not trigger "mouse" events in called element! PerformClick simply sends "click" to element, but without invoking assigned mouse-related events! Therefore, your app may fail to do what it is designed for
I think this should be an easy task. Here is an example code, where elementToCheck is assigned repo element...
Code: Select all
public void CheckIfExists(RepoItemInfo elementToCheck)
{
if (elementToCheck.Exists(5000)) //exists method with search timeout 5s
{
//if exist, do something
}
else
{
//if does not exists, do something else
}
}
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration