Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA

I am not able to run my script in any of the browsers. Below is the error i get for firefox. The location where firefox is installed is correct. Dont know what is wrong.

I am using Firefox 15. Selenium Java 2.2.0 and Eclipse Juno

My test case is given below:

import static org.junit.Assert.*;
import org.junit.After; 
import org.junit.Before; 
import org.junit.Test; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver;  
import org.openqa.selenium.firefox.FirefoxProfile;

public class FirstTest {
private WebDriver _driver;
@Before
 public void setUp() throws Exception {
System.setProperty("webdriver.firefox.driver","C:\\Program Files\\Mozilla Firefox15\\Firefox.exe");
FirefoxProfile firefoxProfile = new FirefoxProfile();
_driver = new FirefoxDriver(firefoxProfile);
}

@Test 
public void Login() throws Exception {
_driver.get("https://www.google.co.in/");
assertEquals("Google", _driver.getTitle());
_driver.findElement(By.id("lst-ib")).clear();
_driver.findElement(By.id("lst-ib")).sendKeys("selenium");
_driver.findElement(By.name("btnG")).click();
_driver.findElement(By.linkText("Selenium - Web Browser Automation")).click();
assertEquals(" ", _driver.getTitle());
assertEquals("Selenium - Web Browser Automation", _driver.getTitle());
}
@After public void tearDown() throws Exception {
_driver.quit();
}
}

Below is the error i get:

org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:59'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_26'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:52)
    at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
    at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:52)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:88)
    at FirstTest.setUp(FirstTest.java:16)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

java.lang.NullPointerException
    at FirstTest.tearDown(FirstTest.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:36)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
like image 448
user2045704 Avatar asked Feb 06 '13 06:02

user2045704


People also ask

Can not find Firefox binary in path?

If you have installed Firefox at a custom location, uninstall existing firefox and install it at a default location. Your firefox should be under "Program Files (x86)" NOT "Program Files" or any other custom location.

How do I find my Firefox path?

Firefox would normally be installed in one of these locations: (64-bit Firefox) "C:\Program Files\Mozilla Firefox\" (32-bit Firefox) "C:\Program Files (x86)\Mozilla Firefox\"

Where is Firefox binary Linux?

To run the version installed with your package manager, you will need to execute the binary from a terminal. To do so in most distributions, open a terminal and type: /usr/bin/firefox .

How do I set the path for Firefox drivers?

setproperty(“webdriver. gecko. driver”,Path_of_Firefox_Driver”); method to set the path of the Firefox Driver(GeckoDriver). Then it has created an object of Firefox Driver to instantiate the Mozilla Firefox browser and execute the test cases.


3 Answers

  1. Open Command line (Start -> Run -> type "cmd")
  2. type PATH
  3. Verify that you can see here written C:\Program Files\Mozilla Firefox15\Firefox.exe

It will be probably not here - because thats what the error says. How to fix it?

  1. Click Start
  2. Right click on "Computer" and click "Properties"
  3. In left menu Choose "Advanced system settings"
  4. Go to tab "Advanced" and click "Environment Variables..."
  5. In the window below select "Path" and click "Edit..." (Admin rights needed)
  6. Add at the end the desired path, semicolon separated
  7. Possible restart of computer needed

It his does not help then change the constructor like this:

File pathToBinary = new File("C:\\Program Files\\Mozilla Firefox15\\Firefox.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
FirefoxProfile firefoxProfile = new FirefoxProfile();
FirefoxDriver _driver = new FirefoxDriver(ffBinary,firefoxProfile);
like image 72
Pavel Janicek Avatar answered Oct 22 '22 04:10

Pavel Janicek


The simplest way is to use the below code before you define your Driver.

System.setProperty("webdriver.firefox.bin",
                    "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
like image 27
Purus Avatar answered Oct 22 '22 06:10

Purus


be attention, if path to browser have space (as example "...\Program Files (x86)...") you need add double quotes to value of param.

Example:

-Dwebdriver.firefox.bin="D:\Program Files (x86)\Mozilla Firefox\firefox.exe"

All has been run successfully when added double quotes.

like image 6
Kosmos Avatar answered Oct 22 '22 04:10

Kosmos