Hi,
I wrote a piece of code that will find a specific URL and close the browser/tab before proceed to next steps. Eg as below :
public void CloseAlBrowsers()
{
IList<Ranorex.WebDocument> AllDoms = Host.Local.FindChildren<Ranorex.WebDocument>();
foreach (WebDocument myDom in AllDoms)
{
//Report.Log(ReportLevel.Info,"BrowserDOM",myDom.PageUrl);
if (myDom.PageUrl.Contains("Google") && myDom.PageUrl.Trim() != "")
{ myDom.Close(); }
}
}
However, this code cannot close the EDGE browser and hit error message "Action 'close' failed on element '{WebDocument:Google}'." Appreciate your assistance. Thanks.
How to close Edge browser or a tab?
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to close Edge browser or a tab?
Hello samantha.chin,
The issue is already known and we are currently working on a solution.
In the meantime you could use the following workaround.
First, add the corresponding tab to the repository.
Within the user code method you could check if the current WebDocument is opened in Microsoft Edge.
If this is the case, a click on the corresponding tab is performed and the tab is closed via the key sequence "CTRL+F4".
I will update this thread when I have new information about the status of the issue.
Regards,
Johannes
The issue is already known and we are currently working on a solution.
In the meantime you could use the following workaround.
First, add the corresponding tab to the repository.
Within the user code method you could check if the current WebDocument is opened in Microsoft Edge.
If this is the case, a click on the corresponding tab is performed and the tab is closed via the key sequence "CTRL+F4".
Code: Select all
IList<Ranorex.WebDocument> AllDoms = Host.Local.FindChildren<Ranorex.WebDocument>();
foreach (WebDocument myDom in AllDoms)
{
if (myDom.PageUrl.Contains("Google") && myDom.PageUrl.Trim() != "")
{
if ( myDom.BrowserVersion == "Microsoft Edge" )
{
repo.MicrosoftEdge.Google.Click();
Keyboard.Press(System.Windows.Forms.Keys.F4 | System.Windows.Forms.Keys.Control, 62, Keyboard.DefaultKeyPressTime, 1, true);
}
else
{
myDom.Close();
}
}
}
Regards,
Johannes
-
- Posts: 10
- Joined: Mon Dec 28, 2015 10:17 am
Re: How to close Edge browser or a tab?
It's worked! Thank you.
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: How to close Edge browser or a tab?
Hello,
The issue was fixed in the latest version of Ranorex, 5.4.5.
The WebDocument.Close() action works now for DOMs in Edge, too.
Sincerely,
Johannes
The issue was fixed in the latest version of Ranorex, 5.4.5.
The WebDocument.Close() action works now for DOMs in Edge, too.
Sincerely,
Johannes