Watin:验证子浏览器的链接并关闭它

发布于 2024-10-04 10:22:38 字数 397 浏览 0 评论 0原文

我正在尝试找到一种关闭子浏览器的方法,其想法是当浏览器弹出时(当前使用 IE 和 mozilla 的选项卡)它将加载然后关闭。

我唯一能想到的是在浏览器打开后插入这个

 IE newIE = new IE();
 newIE.Close();

可悲的是它不起作用。我知道 watin 可以打开两个或三个浏览器,但它可以打开并切换到另一个浏览器,然后返回主浏览器

主浏览器= >子浏览器(关闭此)==>主浏览器

我在这里缺少什么?

我尝试过类似的方法,但它不起作用

IE ie = IE.AttachToIE(Find.ByUrl("google.com"));
ie.Close();

I'm trying to find a way to close a child browser, the idea is when the browser pops up(currently using IE & tab for mozilla)it will load and then closes.

The only thing i can think of is inserting this after the browser opened

 IE newIE = new IE();
 newIE.Close();

Sadly it doesn't worked.I know watin can open two or three browsers but can it open and shift to another browser and then go back to the main browser

Main browser => child browser(close this) => Main browser

What am i missing here?

I tried something like this but it doesn't work

IE ie = IE.AttachToIE(Find.ByUrl("google.com"));
ie.Close();

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

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

发布评论

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

评论(1

梦中楼上月下 2024-10-11 10:22:38

我试图在一些测试中做类似的事情,但我也遇到了一些问题。您可能会发现添加线程睡眠会有所帮助。这就是我所拥有的:

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

I was trying to do something similar in some of my tests and I was having some problems too. You may find that adding a thread sleep will help. This is what I had:

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 和您的相关数据。
原文