简体   繁体   English

带有JUnit的Selenium测试用例脚本在Firefox驱动程序的Eclipse上不起作用

[英]Selenium test case script with JUnit is not working on eclipse for Firefox driver

I have tried with all version of Firefox 45, 48, 49, and 50. I also have to mention the path for the Gecko driver (64 bit) in my program, but still the Firefox browser is not opening once I run my program. 我已经尝试使用所有版本的Firefox 45、48、49和50。我还必须提及程序中Gecko驱动程序(64位)的路径,但是一旦运行程序,Firefox浏览器就无法打开。 I am using Selenium 3.0.1 Java version. 我正在使用Selenium 3.0.1 Java版本。

Here is my code: 这是我的代码:

System.setProperty("webdriver.gecko.driver", "C:\\Users\\Desktop\\ecpipse2\\Selenium Library files\\geckodriver.exe");
driver = new FirefoxDriver();
baseUrl = "http://automationpractice.com/index.php";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

The following error is coming: 出现以下错误:

org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:45120 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700' org.openqa.selenium.WebDriverException:org.apache.http.conn.HttpHostConnectException:连接到localhost:45120 [localhost / 127.0.0.1,localhost / 0:0:0:0:0:0:0:0:1]失败:连接被拒绝:连接构建信息:版本:'未知',版本:'1969d75',时间:'2016-10-18 09:43:45 -0700'
System info: host: 'LAPTOP-C07CIJJB', ip: '192.168.0.6', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102' Driver info: driver.version: FirefoxDriver 系统信息:主机:'LAPTOP-C07CIJJB',ip:'192.168.0.6',操作系统名称:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:'1.8 .0_102'驱动程序信息:driver.version:FirefoxDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91) 在org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) 在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)

If the Gecko driver version is not correct then it doesn't establish a connection with Firefox. 如果Gecko驱动程序版本不正确,则无法与Firefox建立连接。

In the above question, the mentioned error was a little bit confusing which doesn't say about Gecko driver is not compatible with the Selenium web driver and Firefox version. 在上面的问题中,提到的错误有点令人困惑,这并不表示Gecko驱动程序与Selenium Web驱动程序和Firefox版本不兼容。

My case now: It's working fine with Firefox 49.0.2, Selenium webDriver 3.0.1, and Geckodriver.exe 0.11.1. 现在,我的情况是:Firefox 49.0.2,Selenium webDriver 3.0.1和Geckodriver.exe 0.11.1可以正常工作。

The following combination worked fine for me: 以下组合对我来说效果很好:

Firefox: 50 火狐:50

selenium-java: 3.0.1 硒的Java:3.0.1

JUnit: 4.12 JUnit的:4.12

geckodriver.exe: 11.1 geckodriver.exe:11.1

您可以在此处看到一个有效的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM