0

I'm trying to run a very simple test on Selenium, just to start working with it. However, whenever I run a test, it fails, because it cannot find the binary to the browser, be it Firefox or Chrome. I work on a Linux, Ubuntu-based OS (pop-os). I'm programming in Java, and have tried running from both IntelliJ and Eclipse, and neither have worked.

When I tried working with Chrome, my code was the following:

@Test
public void hello() {
    System.setProperty("webdriver.chrome.driver", "drivers/chromedriver");
    ChromeOptions options = new ChromeOptions();
    options.setBinary("/snap/bin/chromium");
    WebDriver browser = new ChromeDriver();
    browser.navigate().to("localhost:8080");
    browser.quit();
}

On the stack trace, it informs that "ChromeDriver was started successfully". Nonetheless, right on the next line, I get the following text: "org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary". I have tried specifying the binary path to the Chromium browser, and also tried copied the binary to the expected place of Chromium on Linux, according to the Selenium website. Neither have worked.

When I tried running Selenium with Firefox, it returns the following message:

org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed.

If I go to the terminal and run 'which firefox', this is the result:

/home/myusername/bin/firefox

so I went back to the terminal and typed vim ~/.bashrc, having added the following line to the end of the file: export PATH="${HOME}/bin:${PATH}". Still, I get the same error, which is

org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed.

Any thoughts on how I could solve my problem? Thanks in advance.

  • 1
    Does this answer your question? https://stackoverflow.com/questions/48213384/how-to-add-chromedriver-to-path-in-linux – Cheshiremoe May 18 '22 at 20:59
  • Does this answer your question? [How to add Chromedriver to PATH in linux?](https://stackoverflow.com/questions/48213384/how-to-add-chromedriver-to-path-in-linux) – Cheshiremoe May 25 '22 at 15:43

0 Answers0