使用 WatiN 处理不同浏览器的弹出窗口

发布于 2024-10-03 04:39:16 字数 150 浏览 0 评论 0原文

我正在使用 WatiN 自动化 Sharepoint 应用程序。在很少的屏幕上,单击按钮或链接会在灯箱弹出窗口中显示附加信息。

浏览器 URL 和弹出窗口 URL 不同,因此无法获取对象的任何引用。

请帮助我解决这个问题,我的所有脚本都需要处理此类灯箱。

I am working with automating a Sharepoint application with WatiN. There are few screen where clicking on button or link additional information will be displayed in a light box pop

The Browser URL and Pop-up Url are different, hence am not able to get the any reference of the objects.

Please help me out with this, all most all of my scripts will need to handle these kind of light boxes.

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

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

发布评论

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

评论(1

怀念你的温柔 2024-10-10 04:39:16

据我了解,如果您的弹出窗口是在新浏览器窗口中显示的页面,则您将需要创建一个新的 WatiN 浏览器实例来访问此“弹出窗口”。

WatiN 提供多种匹配标准来使用 AttachTo() 方法附加浏览器。它必须与搜索说明符结合使用:

  • 按 URL:Find.ByURL()
  • 按 URI:Find.ByURI()
  • 按 Windows 标题:Find.ByTitle()
  • 按窗口句柄:Find.By()

下面是附加 WatiN 的示例IE 浏览器到现有页面,在本例中为弹出窗口,使用他的窗口标题:

IE myPopup = IE.AttachTo<IE>(Find.ByTitle("My Popup title"));

按标题搜索只能使用名称的一部分。按照与前一个示例相同的示例,以下内容也应该与您的弹出窗口匹配:

IE myPopup = IE.AttachTo<IE>(Find.ByTitle("My Popup"));

至于通过 URL 或 URI 查找,它们可能会以与部分匹配相同的方式工作(我推测)。因此,如果您知道弹出窗口打开的 URL 是什么,这可能是一个更好的解决方案。特别是如果 URL 比弹出窗口标题更独特,您将减少附加到错误浏览器的机会。

If your popup is, as I understand them, a page displayed in a new browser window, you will need to create a new WatiN browser instance to access this "popup".

WatiN offer multiple matching criteria to attach a browser using the method AttachTo(). It must be combine with a search specifier:

  • By URL : Find.ByURL()
  • By URI : Find.ByURI()
  • By Windows Title : Find.ByTitle()
  • By Window Handle : Find.By()

Here's an example for attaching a WatiN IE browser to an existing page, in this case your popup, using his window title :

IE myPopup = IE.AttachTo<IE>(Find.ByTitle("My Popup title"));

The search by title can use only a portion of the name. Following the same example as the previous one, the following should also match your popup :

IE myPopup = IE.AttachTo<IE>(Find.ByTitle("My Popup"));

As for the find by URL or URI, they may work the same way with a partial match (I'm speculate). So if you know what is the URL the popup open, it may be a better solution. Especially if the URL is more unique than your popup title, you'll reduce the chance to attach to a wrong browser.

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