org.openqa.selenium.os.UnixProcess checkForError - Selenium doesn't work over jenkins (openshift linux - chrome slave)

情到浓时终转凉″ 提交于 2021-01-28 13:00:40

问题


Selenium code works my local. However it doesn't work over jenkins because of server connection error regarding to jenkins console output.

Jenkins has openshift structure and chrome slave. I've set the configuration that selenium would work on chrome node.

I've also written the selenium codes as bdd (cucumber).

This is how webDriver is initialized:

ChromeOptions options = new ChromeOptions();
System.setProperty("webdriver.chrome.driver","/usr/bin/google-chrome");
options.addArguments("--disable-web-security");
options.addArguments("--ignore-urlfetcher-cert-requests");
options.addArguments("--disable-renderer-backgrounding");
options.addArguments("--disable-infobars");
options.addArguments("--start-maximized");
options.addArguments("--no-sandbox");
if (isHeadless) {
    options.addArguments("--headless");
}
webDriver = new ChromeDriver(options);

The jenkins output is:

2019-02-12 16:14:54 [main] INFO TestingConfig:65 - Loading TestingConfig

(google-chrome:7834): Gtk-WARNING **: 16:14:57.172: cannot open display: Feb 12, 2019 4:15:15 PM org.openqa.selenium.os.UnixProcess checkForError SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)

Scenario: add new scenario # features/AddNewScenario.feature:11 Given I've already display New Scenario Page # AddingNewScenarioTest.iVeAlreadyDisplayScenarioPage() org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start. Build info: version: '3.5.2', revision: '10229a9', time: '2017-08-21T17:29:55.15Z' System info: host: 'jenkins-agent-blue-1', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.1.3.el7.x86_64', java.version: '1.8.0_161' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:254) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:178) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:167) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:156) at com.bmw.scmaer.testing.utils.WebBrowser.init(WebBrowser.java:50) at com.bmw.scmaer.testing.steps.AddingNewScenarioTest.iVeAlreadyDisplayScenarioPage(AddingNewScenarioTest.java:22) at ✽.Given I've already display Scenario Page(features/AddNewScenario.feature:12) Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:3437/status] to be available after 20004 ms at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:102) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:187) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:254) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:137) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:178) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:167) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:156) at com.bmw.scmaer.testing.utils.WebBrowser.init(WebBrowser.java:50)

Additional question: Why did it try to connect to http://localhost:3437/status ?


回答1:


Instead of the absolute location of google-chrome binary you need to pass the absolute location of chromedriver binary within System.setProperty() line as follows:

System.setProperty("webdriver.chrome.driver","/path/to/chromedriver");


来源:https://stackoverflow.com/questions/54667617/org-openqa-selenium-os-unixprocess-checkforerror-selenium-doesnt-work-over-je

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!