I'm currently trying to use Selenium to automate some browsing tasks on Linux (I'm running Linux Mint 20). However, I've ran into a brick wall: I can't get it to locate any browser binaries. I've tried with Firefox and Chromium (thinking that if I could get the Chromium binary to load I'd live with that), but they both yield the same result, Selenium says it can't find the browser binary.
Here is my code:
package test1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class app
{
public static void main(String[] args)
{
System.setProperty("webdriver.firefox.driver", "/home/ann/bin/geckodriver");
WebDriver driver = new FirefoxDriver();
}
}
Here are the results upon running the code:
Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'
System info: host: 'ann-System-Product-Name', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-58-generic', java.version: '11.0.8'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:95)
at java.base/java.util.Optional.orElseGet(Optional.java:369)
at org.openqa.selenium.firefox.FirefoxOptions.getBinary(FirefoxOptions.java:199)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.withOptions(GeckoDriverService.java:180)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:177)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:155)
at test1.app.main(app.java:10)
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Firefox is installed and can be executed from the terminal:
ann@ann-System-Product-Name:~$ whereis firefox
firefox: /usr/bin/firefox /usr/lib/firefox /etc/firefox
Geckodriver is in my $PATH
and executing it gives the following results:
ann@ann-System-Product-Name:~$ geckodriver
1609693404322 geckodriver INFO Listening on 127.0.0.1:4444