Hi,
i am using Ranorex.dll in my C# script in visual studio. I want to wait till a small dialog disappears. I dont want to use thread.Sleep method. So is there any API in ranorex by which I can wait till the dialog disappears.
Thanks,
Bhagya
need a way to wait till a popup disappears
Re: need a way to wait till a popup disappears
This is our framework method for doing so....
To use -
WaitUntilNotExists("rx path to dialog", 60000);
To use -
WaitUntilNotExists("rx path to dialog", 60000);
Code: Select all
/// <summary>
/// Waits until an rxpath does not exist. If the timeout passes and the path still exists, an Exception is thrown. Timeout is specified in ms.
/// </summary>
/// <param name="rxPath"></param>
/// <param name="timeout"></param>
public static void WaitUntilNotExists(string rxPath, int timeout){
timeout = timeout / 1000;
if(timeout < 1 || timeout > 500){throw new Exception("Timeout must be between 1 and 500 seconds.");}
Ranorex.Unknown element = null;
int iterations = 0;
while(Host.Local.TryFindSingle(rxPath, out element)){
Thread.Sleep(1000);
iterations ++;
if(iterations > timeout){
Report.Failure("Item " + rxPath + " still existed after " + timeout.ToString());
throw new RanorexException("Item still existed after timeout.");
}
}
}
Re: need a way to wait till a popup disappears
Similarly, here is the method I use... One thing that makes sdaly's method better is that he is using a variable for timeout so that you don't wait too long for the window to disappear.
Code: Select all
bool WindowVisible = MyWindow.Visible;
while (WindowVisible == true)
{
Thread.Sleep(500);
WindowVisible = MyWindow.Visible;
}
Last edited by Ciege on Tue Apr 24, 2012 4:11 pm, edited 1 time in total.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: need a way to wait till a popup disappears
The Ranorex Recorder also has a built in "Wait For Not Exists" action. Just select the repository item corresponding to your popup window and a maximum timeout to wait.
See the corresponding Ranorex User Guide section:
http://www.ranorex.com/support/user-gui ... tions.html
Regards,
Alex
Ranorex Team
See the corresponding Ranorex User Guide section:
http://www.ranorex.com/support/user-gui ... tions.html
Regards,
Alex
Ranorex Team
Re: need a way to wait till a popup disappears
Thanks for the code snnipet. I tried it and its working.
I also want to know if I am using Ranorex.dll in my visual studio solution, then why all the methods (ex. WaitTillnotExists) are not visible to me. Am I missing any other dll?
I also want to know if I am using Ranorex.dll in my visual studio solution, then why all the methods (ex. WaitTillnotExists) are not visible to me. Am I missing any other dll?
Re: need a way to wait till a popup disappears
The "WaitUntilNotExists" method and the snippet I posted are both user generated code snippets not in the Ranorex DLL.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: need a way to wait till a popup disappears
Additionally, make sure that you also add references to all Ranorex.Plugin.*.dll assemblies. Take a look at this section in the Ranorex User Guide for more info.bhagya wrote:I also want to know if I am using Ranorex.dll in my visual studio solution...
Regards,
Alex
Ranorex Team