使用 WatiN 处理不同浏览器的弹出窗口
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解,如果您的弹出窗口是在新浏览器窗口中显示的页面,则您将需要创建一个新的 WatiN 浏览器实例来访问此“弹出窗口”。
WatiN 提供多种匹配标准来使用 AttachTo() 方法附加浏览器。它必须与搜索说明符结合使用:
下面是附加 WatiN 的示例IE 浏览器到现有页面,在本例中为弹出窗口,使用他的窗口标题:
按标题搜索只能使用名称的一部分。按照与前一个示例相同的示例,以下内容也应该与您的弹出窗口匹配:
至于通过 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:
Here's an example for attaching a WatiN IE browser to an existing page, in this case your popup, using his window 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 :
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.