Long time no see.

I am doing automation test using Ranorex APIs. Now I have a problem about closing browser windows.
Here attachment is the screenshot I got when I ran my test in Visual Studio.
Thanks alot in advance!
yinghu
Code: Select all
wd.close
Ciege wrote:How about just use.Code: Select all
wd.close
You should probably put it in a try/catch block to catch and handle any exceptions just in case.
Host.Local.OpenBrowser("http://www.ranorex.com", "IE"); Delay.Seconds(3); Ranorex.WebDocument wd = Host.Local.FindSingle<Ranorex.WebDocument>("/dom[@domain='www.ranorex.com' and @caption='Test Automation Tools - Ranorex Automation Framework']"); Validate.Exists(wd.GetPath()); //Host.Local.CloseApplication(wd, new Duration(0)); wd.Close();You can use "CloseApplication" or "Close". Both of them work.
Support Team wrote:Hello,
Which version of Ranorex do are you using?
Here is a little code snippet which works as expected.Host.Local.OpenBrowser("http://www.ranorex.com", "IE"); Delay.Seconds(3); Ranorex.WebDocument wd = Host.Local.FindSingle<Ranorex.WebDocument>("/dom[@domain='www.ranorex.com' and @caption='Test Automation Tools - Ranorex Automation Framework']"); Validate.Exists(wd.GetPath()); //Host.Local.CloseApplication(wd, new Duration(0)); wd.Close();You can use "CloseApplication" or "Close". Both of them work.
Which domain do you use to open the browser? It could be that you use e.g. http://www.yyy.com to open the browser and yyy.com to close it. Please check the RxPath of the element.
Regards,
Bernhard
sdaly wrote:Could be similar to this - http://www.ranorex.com/forum/browser-cl ... t3306.html
Support Team wrote:Hello,
Could you please explain exactly what you are doing in your code?
Additionally please check with Ranorex Spy if the path to the web document you are trying to close is correct.
Thank you!
Regards,
Bernhard
Code: Select all
Form f = null;
if (this.windowTestObject.GetType() == typeof(Ranorex.WebDocument))
{
f = ((Ranorex.WebDocument)this.windowTestObject).Browser;
} else if (windowTestObject.GetType() == typeof(Ranorex.Form)){
f = (Form)this.windowTestObject;
}
PopupWatcher closePopupWatcher = new PopupWatcher();
closePopupWatcher.Watch(f.GetPath(), CloseUpdateCheckDialog);
closePopupWatcher.Start();
f.Close();
}
....
//Popup Closer
public static void CloseUpdateCheckDialog(Ranorex.Core.RxPath myPath, Ranorex.Core.Element parentElement)
{
int processId = ((Ranorex.NativeWindow)parentElement).ProcessId;
Process proc = Process.GetProcessById(processId);
proc.Kill();
}