I am using webdrivermanager plugin by Boni Garcia for driver installation. When I use it for execution on my local and everything working fine but I face issues when I try to do the same via Jenkins. Details below:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.3.0</version>
</dependency>
Now when I try to execute the same maven project via Jenkins, I am facing issue. My slave machine is a docker machine.
At first, I tried webdrivermanager to take care of the chrome driver installation and I got error stating that binary not found.
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
options.addArguments("start-maximized");
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver(options);
Error:
org.openqa.selenium.WebDriverException:
unknown error: cannot find Chrome binary
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Linux 3.10.0-862.14.4.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Then I tried using driver from within the framework. I saved the chromedriver file in a drivers folder within my framework and then tried to execute it, but still got an error (different error this time though)
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
options.addArguments("start-maximized");
System.setProperty("webdriver.chrome.driver", "src/test/resources/drivers/chromedriver");
driver = new ChromeDriver(options);
Error:
Running TestSuite
/home/jenkins/workspace/Dental_EIEI_Angular/EIEI Test Jenkins/src/test/resources/drivers/chromedriver: /home/jenkins/workspace/Dental_EIEI_Angular/EIEI Test Jenkins/src/test/resources/drivers/chromedriver: cannot execute binary file
Apr 03, 2019 2:19:23 PM org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 126 (Exit value: 126)