user177060
user177060

Reputation: 11

how to close a child browser in c# or WatiN?

I want to close the child window which is of "Browser" type. Have a look at the below code.

WatiN.Core.Browser openBrowser = BrowserType.getBrowserObject().attachChildBrowser(document_name + Constants.open_document_title);

I want to close the "openBrowser". Close()(available in WatiN) can only be used for the type "IE" of "Firefox" only. So, I cant use Close() method also. Is there any method to close the browser in C# or WatiN?

Upvotes: 1

Views: 1633

Answers (1)

Jen Bandelin
Jen Bandelin

Reputation: 193

Have you tried using the IE type instead of the browser type? You could try something like this:

System.Threading.Thread.Sleep(5000);
IE popUpWindow = IE.AttachTo<IE>.Find.ByUrl(s=>s.StartsWith("http://www.google.com")));
Assert.IsTrue(popUpWindow.Title.Contains("google - Google Search"));
popUpWindow.Close();

Upvotes: 2

Related Questions