Reputation: 81
For my selenium automated test in Github Actions, in my test setup, I am trying to open the FireFox driver. The code is given below.
System.setProperty("webdriver.gecko.driver","Drivers/geckodriver");
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true);
driver = new FirefoxDriver(options);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
The above code works fine. However the problem is that I have two github accounts. The code works without any issues in one of the Github accounts but the same code fails in another Github account.
Here is the exception that I am getting:
java.lang.IllegalStateException: Can't start Web Driver
at src.test.java.tests.LoginTest.setup(LoginTest.java:86)
Caused by:
org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'f559711d91c1', ip: '172.18.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.11.0-1025-azure', java.version: '1.8.0_282'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:100)
at java.util.Optional.orElseGet(Optional.java:267)
at org.openqa.selenium.firefox.FirefoxOptions.getBinary(FirefoxOptions.java:216)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:187)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)
at src.test.java.tests.LoginTest.setup(LoginTest.java:80)
I tried with both Firefox and Chrome driver but both the options failed.
For chrome driver, I tried by adding the following arguments but none of the options worked for chrome.
options.setBinary("Drivers/chromedriver");
options.addArguments("--no-sandbox");
options.addArguments("--headless");
options.addArguments("--whitelisted-ips");
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("--disable-infobars");
options.addArguments("--disable-dev-shm-usage");
The following exception keeps happening
setup FAILED
java.lang.IllegalStateException: Can't start Web Driver
at src.test.java.tests.LoginTest.setup(LoginTest.java:86)
Caused by:
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 Drivers/chromedriver 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: '27c5f10fefbb', ip: '172.18.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.11.0-1025-azure', java.version: '1.8.0_282'
Driver info: driver.version: ChromeDriver
Upvotes: 3
Views: 1130
Reputation: 193298
This error message...
setup FAILED
java.lang.IllegalStateException: Can't start Web Driver
at src.test.java.tests.LoginTest.setup(LoginTest.java:86)
Caused by:
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 Drivers/chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. google-chrome session.
Your main issue seems to be with the method setBinary():
options.setBinary(new File("/path/to/chrome"));
Instead of ChromeDriver you need to pass the absolute location of the Google Chrome executable.
Effectively, your line of code will be:
options.setBinary("/path/to/chrome");
Upvotes: 1