When I launched Selenium tests In Jenkins with Maven on CentOS 7 I got:
unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn’t exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Full error:
org.openqa.selenium.WebDriverException:
unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'testenv', ip: '192.168.3.33', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-693.17.1.el7.x86_64', java.version: '1.8.0_152'
Driver info: driver.version: ChromeDriver
remote stacktrace: #0 0x561bcf9f2479
I’d already installed Google Chrome on CentOS 7 Minimal as follows:
1 2 |
# wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm # yum localinstall google-chrome-stable_current_x86_64.rpm |
And Google Chrome version is 79.0.3945.117-1
Corresponding ChromeDriver 79.0.3945.36 was downloaded from here: https://chromedriver.chromium.org/downloads
The test server has CentOS 7 Minimal installed without graphical interface so in order to launch Selenium tests as Maven job in Jenkins on CentOS 7 the “headless” and “no-sandbox” options must be used in ChromeDriver settings (lines 23-26):
1 |
# cat WebDriverSettings.java |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
package settings; import org.junit.After; import org.junit.BeforeClass; import org.openqa.selenium.Point; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.util.HashMap; public class WebDriverSettings { public static WebDriver driver; @BeforeClass public static void setUp() { String downloadFilepath = System.getProperty("downloadFilepath"); HashMap<String, Object> chromePrefs = new HashMap<>(); chromePrefs.put("profile.default_content_settings.popups", 0); chromePrefs.put("download.default_directory", downloadFilepath); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("prefs", chromePrefs); options.addArguments("--no-sandbox"); options.addArguments("--headless"); //should be enabled for Jenkins options.addArguments("--disable-dev-shm-usage"); //should be enabled for Jenkins options.addArguments("--window-size=1920x1080"); //should be enabled for Jenkins driver = new ChromeDriver(options); Point point = new Point(-1000, 0); String baseUrl = System.getProperty("testUrl"); driver.get(baseUrl); } @After public void endTests() { driver.close(); } } |
Good luck!