Close all browsers

Ask general questions here.
SanMan
Posts: 147
Joined: Tue Apr 13, 2010 9:59 am

Close all browsers

Post by SanMan » Fri Apr 20, 2018 1:07 pm

When I run this:

public void CloseAlBrowsers()
{

IList<Ranorex.WebDocument> AllDoms = Host.Local.FindChildren<Ranorex.WebDocument>();

if (AllDoms.Count >=1)
{
foreach (WebDocument myDom in AllDoms)
{
myDom.Close();
}
}
}


Action 'close' failed on element '{WebDocument:Startpage}'.
Error HRESULT E_FAIL has been returned from a call to a COM component.

What is the problem here why I get this error?

ahoisl
Certified Professional
Certified Professional
Posts: 125
Joined: Fri Sep 07, 2007 8:16 am

Re: Close all browsers

Post by ahoisl » Fri Apr 20, 2018 10:36 pm

Such COM errors usually come from IE. Could this be some embedded IE control within an application that you just cannot close? Can you check in spy if you find that DOM?
Or you may try just catching the exception, logging it and continue with the other DOMs.

Regards,
Alex
Ranorex Team