如何在 C# 或 WatiN 中关闭子浏览器?

发布于 2024-08-26 21:32:39 字数 282 浏览 6 评论 0原文

我想关闭“浏览器”类型的子窗口。看看下面的代码。

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

我想关闭“openBrowser”。 Close()(WatiN 中可用)只能用于“Firefox”类型“IE”。所以,我也不能使用 Close() 方法。 C# 或 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只想待在家 2024-09-02 21:32:39

您是否尝试过使用 IE 类型而不是浏览器类型?你可以尝试这样的事情:

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();

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文