3

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
ouflak
  • 2,458
  • 10
  • 44
  • 49
Harish
  • 81
  • 1
  • 5

1 Answers1

1

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. 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.


Solution

Effectively, your line of code will be:

options.setBinary("/path/to/chrome");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Hi, I already tried to set binary path but it gives following exception,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.) – Harish Jan 20 '22 at 13:57
  • 1
    It isn't about tried to set binary path, but to pass the correct type of argument. However, the error _`DevToolsActivePort file doesn't exist`_ is a known issue and can be solved and addressed more comfortably. But it should be a different question altogether. – undetected Selenium Jan 20 '22 at 13:58