如何测试IE弹出窗口的内容

发布于 2024-09-26 01:37:31 字数 760 浏览 0 评论 0原文

我正在使用 Watin 和 Nant 为我的网站创建单元测试。

我想知道如何测试弹出的 IE 窗口的内容。 当用户单击包含 target="_blank" 的链接时,该窗口就会打开,如下例所示

<p>
... receives oversight and governance from the 
<a target="_blank" href="ihealth.html">iHealth Alliance</a>,
a not-for-profit organization ....  </p>

这是我尝试使用的代码:

_ie = new IE(SITE_ROOT);
_ie.Link(f => f.Text == "iHealth Alliance").Click();
//here i need to enter something to check if popup window has appropriate title
//something like Assert.AreEqual("My page title to test", _ie.ChildWindows[0].Title)

如我所见,Watin 的 API 允许在一个 IE 窗口中搜索控件,但是,由于某种原因,它不会跟踪由于主窗口工作而打开的新窗口。 肯定应该有像 ChildWindows 或 PopupWindows 集合之类的东西,

你能建议我如何做到这一点吗?

谢谢你!

I'm using Watin and Nant to create unit tests for my web site.

I want to know the way how to test content of the popup IE window.
That window is opening when user clicks on the link that has target="_blank", like on the example below

<p>
... receives oversight and governance from the 
<a target="_blank" href="ihealth.html">iHealth Alliance</a>,
a not-for-profit organization ....  </p>

Here is the code I'm trying to use:

_ie = new IE(SITE_ROOT);
_ie.Link(f => f.Text == "iHealth Alliance").Click();
//here i need to enter something to check if popup window has appropriate title
//something like Assert.AreEqual("My page title to test", _ie.ChildWindows[0].Title)

As i can see, Watin's API allows to search for controls within one IE window, but, for some reason, it does not track for new windows that is opening as result of working primary window.
There definitely should be something like ChildWindows or PopupWindows collections

Can you suggest me the way of how i can do that?

Thank you!

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

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

发布评论

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

评论(1

和我恋爱吧 2024-10-03 01:37:31

我找到了这个问题的解决方案

Browser.AttachTo() 允许附加到任何 IE 窗口,并且可以按十几个标准进行搜索
所以,我的代码将如下所示:

_ie = new IE(SITE_ROOT);
_ie.Link(f => f.Text == "iHealth Alliance").Click();

Assert.IsNotNull(Browser.AttachTo<IE>(Find.ByTitle("My page title to test")));

I found the solution for this thing

Browser.AttachTo() allows to attach to any IE window and it lets to search by dozen criteries
So, my code will look like:

_ie = new IE(SITE_ROOT);
_ie.Link(f => f.Text == "iHealth Alliance").Click();

Assert.IsNotNull(Browser.AttachTo<IE>(Find.ByTitle("My page title to test")));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文