selenium 3.12 和 geckodrvier 0.21.0 是否兼容且稳定,在 linux 机器上跳过所有测试
Is selenium 3.12 and geckodrvier 0.21.0 are compatible and stable, all tests gets skipped on linux machine
平台详情:
geckodriver 0.21.0 , Firefox: 60, Selenium: 3.12, cent Os 7
当我 运行 它使用 mvn 成功启动时:
geckodriver INFO Listening on 127.0.0.1:14185
Marionette INFO Listening on port 284135
在 windows 机器上测试 运行 成功,但是当 运行 在 CentOs 7 上进行相同测试时,测试被跳过。
我观察到所有测试都被跳过,因为 Firefox 的 GUI 在一段时间后关闭,并在 cmd 控制台上显示以下信息和错误:
INFO: org.openqa.selenium.WebDriverException: java.io.IOException:
unexpected end of stream on Connection{localhost:33365, proxy=DIRECT
hostAddress=localhost/12 6.10.0.1:258107
[ERROR] java.net.ConnectException: Failed to connect to
localhost/127.0.0.1:2285
/bin/sh: line 1: 8780 Killed
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java
if(platform.equalsIgnoreCase("linux")) {
FirefoxOptions options = new FirefoxOptions();
DesiredCapabilities desiredCap = DesiredCapabilities.firefox();
profile.setPreference("browser.download.dir",System.getProperty("user.dir")+ File.separator + "target");
System.setProperty("webdriver.gecko.driver", "/path/geckodriver/geckodriver");
System.setProperty("webdriver.firefox.bin","/usr/bin/firefox/firefox");
desiredCap.setCapability(CapabilityType.PLATFORM_NAME,Platform.LINUX);
desiredCap.setCapability("webdriver.firefox.profile",DesiredCapabilities.firefox());
driver = new FirefoxDriver();
}
我花了很多时间在这上面,但找不到根本原因。
使用 maven surefire 插件 2.19.1.
请帮助我,我真的被困在这里了。
根据下面的文档,您在问题中提到的二进制文件的组合(Selenium v3.12 / GeckoDriver v0.21.0 / Firefox v60) 兼容稳定如下:
这个错误信息...
INFO: org.openqa.selenium.WebDriverException: java.io.IOException: unexpected end of stream on Connection{localhost:33365, proxy=DIRECT hostAddress=localhost/12 6.10.0.1:258107
[ERROR] java.net.ConnectException: Failed to connect to localhost/127.0.0.1:2285
...意味着 GeckoDriver 无法 initiate/spawn 新的 WebBrowser 即 Firefox浏览器 会话。
正如您提到的关于使用 GeckoDriver v0.21.0 没有必要提到 setProperty
和 webdriver.firefox.bin
。您需要确保 Mozilla Firefox 安装在每个系统的默认位置。
解决方案
- 根据您的代码试验,尽管您已经创建并配置了
FirefoxOptions
Class 和 DesiredCapabilities
Class 对象,你在初始化 WebDriver. 时没有传递它们
- 如果您的 usecase 需要
FirefoxOptions
Class 和 DesiredCapabilities
Class 对象,您需要在初始化期间传递它们WebDriver 和 Web 浏览器。
- 如果您的用例不需要
FirefoxOptions
Class和DesiredCapabilities
Class 您需要删除的对象。
我觉得你的代码没问题。
检查自动化中使用的所有进程,确保不是多个进程运行。最重要的是:
ps -ef|grep firefox
ps -ef|grep geckodriver
ps -ef|grep java
多进程关闭运行
检查任何错误日志:
sudo vi /var/log/messages
Find for Kill 或 ERROR.This 应该可以帮助解决问题。
平台详情:
geckodriver 0.21.0 , Firefox: 60, Selenium: 3.12, cent Os 7
当我 运行 它使用 mvn 成功启动时:
geckodriver INFO Listening on 127.0.0.1:14185
Marionette INFO Listening on port 284135
在 windows 机器上测试 运行 成功,但是当 运行 在 CentOs 7 上进行相同测试时,测试被跳过。
我观察到所有测试都被跳过,因为 Firefox 的 GUI 在一段时间后关闭,并在 cmd 控制台上显示以下信息和错误:
INFO: org.openqa.selenium.WebDriverException: java.io.IOException: unexpected end of stream on Connection{localhost:33365, proxy=DIRECT hostAddress=localhost/12 6.10.0.1:258107
[ERROR] java.net.ConnectException: Failed to connect to localhost/127.0.0.1:2285
/bin/sh: line 1: 8780 Killed /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre/bin/java
if(platform.equalsIgnoreCase("linux")) {
FirefoxOptions options = new FirefoxOptions();
DesiredCapabilities desiredCap = DesiredCapabilities.firefox();
profile.setPreference("browser.download.dir",System.getProperty("user.dir")+ File.separator + "target");
System.setProperty("webdriver.gecko.driver", "/path/geckodriver/geckodriver");
System.setProperty("webdriver.firefox.bin","/usr/bin/firefox/firefox");
desiredCap.setCapability(CapabilityType.PLATFORM_NAME,Platform.LINUX);
desiredCap.setCapability("webdriver.firefox.profile",DesiredCapabilities.firefox());
driver = new FirefoxDriver();
}
我花了很多时间在这上面,但找不到根本原因。 使用 maven surefire 插件 2.19.1.
请帮助我,我真的被困在这里了。
根据下面的文档,您在问题中提到的二进制文件的组合(Selenium v3.12 / GeckoDriver v0.21.0 / Firefox v60) 兼容稳定如下:
这个错误信息...
INFO: org.openqa.selenium.WebDriverException: java.io.IOException: unexpected end of stream on Connection{localhost:33365, proxy=DIRECT hostAddress=localhost/12 6.10.0.1:258107
[ERROR] java.net.ConnectException: Failed to connect to localhost/127.0.0.1:2285
...意味着 GeckoDriver 无法 initiate/spawn 新的 WebBrowser 即 Firefox浏览器 会话。
正如您提到的关于使用 GeckoDriver v0.21.0 没有必要提到 setProperty
和 webdriver.firefox.bin
。您需要确保 Mozilla Firefox 安装在每个系统的默认位置。
解决方案
- 根据您的代码试验,尽管您已经创建并配置了
FirefoxOptions
Class 和DesiredCapabilities
Class 对象,你在初始化 WebDriver. 时没有传递它们
- 如果您的 usecase 需要
FirefoxOptions
Class 和DesiredCapabilities
Class 对象,您需要在初始化期间传递它们WebDriver 和 Web 浏览器。 - 如果您的用例不需要
FirefoxOptions
Class和DesiredCapabilities
Class 您需要删除的对象。
我觉得你的代码没问题。
检查自动化中使用的所有进程,确保不是多个进程运行。最重要的是:
ps -ef|grep firefox
ps -ef|grep geckodriver
ps -ef|grep java
多进程关闭运行
检查任何错误日志:
sudo vi /var/log/messages
Find for Kill 或 ERROR.This 应该可以帮助解决问题。