我试图通过selenium-java库实现页面登录。我使用的驱动程序是Chromium(chrome的开源版本)。该实现在Windows环境中运行良好,但是当我通过Jenkins(Linux box)运行该实现时,驱动程序无法启动。我希望在实例化ChromeDriver时不会看到任何问题,并且应该可以毫无问题地启动它。
以下是Linux环境的详细信息。
我确保并验证了该文件具有从Jenkins用户执行的完整权限。
我正在尝试的代码
String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
ChromeOptions options = new ChromeOptions();
if (OS.indexOf("win") >= 0) {
filePath = new File(properties.getChromeDriverPath()).getAbsolutePath();
System.setProperty("webdriver.chrome.driver", filePath);
} else if (OS.indexOf("nux") >= 0) {
File chromiumDriver = new File("/usr/bin/chromium-browser");
System.setProperty("webdriver.chrome.driver", chromiumDriver.getAbsolutePath());
}
options.setHeadless(true);
WebDriver chromeDriver = new ChromeDriver(options);
错误日志。
com.src.test.services.integration.test.AuthServicesTest > testAuthentication STANDARD_ERROR
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'xyzJenkinsHost.test.corp', ip: '172.20.3.2', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.14.4.el7.x86_64', java.version: '1.8.0_131'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:193)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:179)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
com.src.test.services.integration.test.AuthServicesTest > testAuthentication STANDARD_ERROR
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:19154/status] to be available after 20002 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:188)
... 21 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:156)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
... 22 more
答案 0 :(得分:0)
此错误消息...
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'xyzJenkinsHost.test.corp', ip: '172.20.3.2', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.14.4.el7.x86_64', java.version: '1.8.0_131'
Driver info: driver.version: ChromeDriver
...表示 ChromeDriver 无法启动/产生新的 Web浏览会话,即 Chrome浏览器会话。
您的主要问题是所使用的二进制版本之间的不兼容性:
因此 JDK v8u6131 和 Selenium Client v3.141.59 之间存在明显的不匹配。
答案 1 :(得分:0)
File chromiumDriver = new File("/usr/bin/chromium-browser");
System.setProperty("webdriver.chrome.driver", chromiumDriver.getAbsolutePath());
您正在将webdriver.chrome.driver
系统属性设置为chromium-browser
的位置。相反,您必须将属性设置为指向chromdriver
可执行文件所在的位置(应该将其下载到某个地方)。