Reputation: 139
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: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'skalia', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-25-generic', java.version: '1.8.0_111'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:75)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
at pack.SeleTest.main(SeleTest.java:10)
This is the error i get during running selenium script which is working Fine on Window PC. I set all the Build path. Add all selenium jars. Help me to solve it.
Upvotes: 2
Views: 18142
Reputation: 1491
IN JAVA Language:
If you install firefox in default location you just write:
WebDriver driver = new FirefoxDriver();
For other location you can coding like below:
File browserAppPath = null;
if (Platform.getCurrent().is(Platform.WINDOWS)) {
browserAppPath = new File("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
if (!browserAppPath.exists()) {
browserAppPath = new File("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
}
} else {
// Ubuntu
browserAppPath = new File("/usr/bin/firefox/firefox-bin");
}
WebDriver driver = new FirefoxDriver( new FirefoxBinary(browserAppPath), new FirefoxProfile());
Upvotes: 3
Reputation: 4820
Either add your Firefox binary to the PATH variable or set it programmatically using a constructor of FirefoxDriver
taking a FirefoxBinary
, like this one:
FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile);
To find out the path to your firefox binary on Linux, run this command in a shell:
which firefox
If this does not show a path or shows an error nessage, then Firefox is not installed on your Linux system (if it is installed on your Windows PC, then this is the reason why it works there).
Upvotes: 2