问题描述
我希望能够在 Selenium 2 的新选项卡中打开一个链接.我还想在完成与页面的交互后关闭该选项卡.如果我有一个 <a>
标签的 WebElement
,这怎么可能?
I want to be able to open a link in a new tab in Selenium 2. Also i want to close the tab when i am finished interacting with the page. How is this possible if I have a WebElement
of an <a>
tag?
我正在使用 Selenium 2 的 Java API 和 Firefox 驱动程序,在 Firefox 4 上运行.
I am using the Java API of Selenium 2 with the Firefox Driver, running on Firefox 4.
推荐答案
目前,Selenium WebDriver API 没有任何处理选项卡的方法.该项目确实需要一套一致的、跨浏览器的方法来管理选项卡,然后我才会期望看到一种语言绑定(如 Java)的实现.在那之前,您的 JavaScript 解决方案可能是唯一的方法,请记住,您的代码将负责管理该选项卡的生命周期.
At the moment, the Selenium WebDriver API doesn't have any way of handling tabs. The project would really need a consistent, cross-browser set of methods for managing tabs before I would expect to see an implementation in one of the language bindings like Java. Until then, your JavaScript solution may be the only way, and remember that your code would then be responsible for managing the lifetime of that tab.
这篇关于Selenium 2:在新标签中打开链接并关闭标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!