硒2.53不适用于Firefox 47 [英] Selenium 2.53 not working on Firefox 47
问题描述
org.openqa.selenium.firefox.NotConnectedException:无法连接到WebDriver。
在45000毫秒后在端口7055上托管127.0.0.1。
- Firefox版本:47.0
- Selenium:2.53.0
- Windows 10 64位
是否有人遇到类似的问题或任何想法是什么解决这个?它的工作正常与Chrome浏览器,但与Firefox没有任何URL正在加载。
不幸的Selenium WebDriver 2.53.0不兼容与Firefox 47.0。处理Firefox浏览器的WebDriver组件( FirefoxDriver
)将停止运行。从3.0版开始,Selenium WebDriver将具有 MarionetteDriver
作为Firefox测试的默认运行实现。更多信息此处和这里。
因此,为了使用Firefox 47.0作为Selenium WebDriver 2.53的浏览器。 0,您需要下载木偶驱动程序(这是一个名为 geckodriver
自版本0.8.0开始,以前是 wires
的二进制文件),并将其绝对路径导出到变量 webdriver.gecko.driver
作为Java代码中的系统属性:
System.setProperty(webdriver.gecko.driver,/ path / to / geckodriver);
幸运的是,库可以为你做这个工作,即为你的机器(Linux,Mac或Windows)下载合适的Marionette二进制文件,并导出适当系统属性的值。要使用这个库,你需要在你的项目中包含这个依赖项:
< dependency>
< groupId> io.github.bonigarcia< / groupId>
< artifactId> webdrivermanager< / artifactId>
< version> 1.7.2< / version>
< /依赖>
...然后在使用WebDriver之前在您的程序中执行此行:
FirefoxDriverManager.getInstance()。setup();
使用WebDriver和Marionette的JUnit测试用例的完整运行示例如下所示:
public class FirefoxTest {
受保护的WebDriver驱动程序;
@BeforeClass
public static void setupClass(){
FirefoxDriverManager.getInstance()。setup(); (
)
@Before
public void setupTest(){
driver = new FirefoxDriver();
$ b $ After
public void teardown(){
if(driver!= null){
driver.quit();
@Test
public void test(){
//你的测试代码
}
}考虑到Marionette将是未来唯一的选择(对于WebDriver 3+和Firefox 48+ ),但是目前(写入时版本0.9.0)不是很稳定。看一看木偶路线图进一步的细节。
更新
Selenium WebDriver 2.53。 1 已于2016年6月30日发布。 FirefoxDriver
正与Firefox 47.0.1 一起作为浏览器使用。
I am getting error while using Firefox with WebDriver.
org.openqa.selenium.firefox.NotConnectedException: Unable to connect
to host 127.0.0.1 on port 7055 after 45000 ms.
- Firefox version:47.0
- Selenium:2.53.0
- Windows 10 64 bit
Is anyone getting a similar issue or any idea what is the solution for this? It's working fine with Chrome but with Firefox none of the URLs are getting loaded.
解决方案 Unfortunately Selenium WebDriver 2.53.0 is not compatible with Firefox 47.0. The WebDriver component which handles Firefox browsers (FirefoxDriver
) will be discontinued. As of version 3.0, Selenium WebDriver will have MarionetteDriver
as the default running implementation for Firefox tests. More info here and here.
Therefore, in order to use Firefox 47.0 as browser with Selenium WebDriver 2.53.0, you need to download the Marionette driver (which is a binary file called geckodriver
as of version 0.8.0, and formerly wires
) and export its absolute path to the variable webdriver.gecko.driver
as a system property in your Java code:
System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");
Luckily, the library WebDriverManager can do this work for you, i.e. download the proper Marionette binary for your machine (Linux, Mac, or Windows) and export the value of the proper system property. To use this library, you need to include this dependency into your project:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>1.7.2</version>
</dependency>
... and then execute this line in your program before using WebDriver:
FirefoxDriverManager.getInstance().setup();
A complete running example of a JUnit test case using WebDriver and Marionette could be as follows:
public class FirefoxTest {
protected WebDriver driver;
@BeforeClass
public static void setupClass() {
FirefoxDriverManager.getInstance().setup();
}
@Before
public void setupTest() {
driver = new FirefoxDriver();
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void test() {
// Your test code here
}
}
Take into account that Marionette will be the only option for future (for WebDriver 3+ and Firefox 48+), but currently (version 0.9.0 at writing time) is not very stable. Take a look to the Marionette roadmap for further details.
UPDATE
Selenium WebDriver 2.53.1 has been released on 30th June 2016. FirefoxDriver
is working again with Firefox 47.0.1 as browser.
这篇关于硒2.53不适用于Firefox 47的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!