Hi all,
I'm using Ranorex ver. 4.0.4 for my automation test.
We have a web application witch open popups to fill some fields (for other information).
I'm wondering if there is a way to close all windows on fail.
Can someone help me?
Thanx
Max
How to close all windows
Re: How to close all windows
You could get an IList of all Forms on the Host, then loop that list closing each.
Make a Google search of this "c# close all open windows" and you will get many other answers to your question.
Make a Google search of this "c# close all open windows" and you will get many other answers to your question.
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...
-
- Posts: 20
- Joined: Thu May 09, 2013 10:44 am
Re: How to close all windows
thanx a lot ... 
I'll try immediately

I'll try immediately
-
- Posts: 20
- Joined: Thu May 09, 2013 10:44 am
Re: How to close all windows
ok, now I have this method in my test:
it works, but it kill process bound to my browser (we have a multi-browser application).
It's fine, but now, on error, the error behavior, setted on "Continue with iteration", is not working.
It's because I don't invoke the "Close Application" on my teardown anymore?!?
tnx
Max
Code: Select all
private void closeAllWindows()
{
System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcessesByName(browser);
for (int i=0; i<process.Length; i++)
{
try
{
System.Diagnostics.Process p = (System.Diagnostics.Process)process.GetValue(i);
p.Kill();
p.WaitForExit(); // possibly with a timeout
}catch (Exception e){
Report.Error(e.StackTrace);
}
}
}
It's fine, but now, on error, the error behavior, setted on "Continue with iteration", is not working.
It's because I don't invoke the "Close Application" on my teardown anymore?!?
tnx
Max
Re: How to close all windows
You can try to use xpath to search for the open browser windows, and use the close method on them.
Code: Select all
IList<Ranorex.WebDocument> webList = Host.Local.Find<Ranorex.WebDocument>("/dom[@dom='yoursite']");
foreach (Ranorex.WebDocument webdoc in webList)
{
webdoc.Close();
}
-
- Posts: 20
- Joined: Thu May 09, 2013 10:44 am
Re: How to close all windows
wow ... it seems to be better ...
I'll try then I'll tell you
Thanx
Max
I'll try then I'll tell you
Thanx
Max