Selenium 2:在新标签页中打开链接并关闭标签页 [英] Selenium 2: Open link in new tab and close tabs

查看:298
本文介绍了Selenium 2:在新标签页中打开链接并关闭标签页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在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 4上运行的Firefox驱动程序。

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:在新标签页中打开链接并关闭标签页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆