Selenium 2: Open link in new tab and close tabs(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 驱动程序,在 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:在新标签中打开链接并关闭标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Selenium 2:在新标签中打开链接并关闭标签
				
        
 
            
        基础教程推荐
- 从 python 访问 JVM 2022-01-01
 - 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
 - 在 Java 中创建日期的正确方法是什么? 2022-01-01
 - 大摇大摆的枚举 2022-01-01
 - 多个组件的复杂布局 2022-01-01
 - 验证是否调用了所有 getter 方法 2022-01-01
 - Java 实例变量在两个语句中声明和初始化 2022-01-01
 - 不推荐使用 Api 注释的描述 2022-01-01
 - 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
 - Java Swing计时器未清除 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				