15
votes

I am trying to config proxy settings for the WebDriver so I have used the following code ....

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http","207.229.122.162");
profile.setPreference("network.proxy.http_port", 3128); 
WebDriver driver = new FirefoxDriver(profile);
selenium = new WebDriverBackedSelenium(driver, "http://www.example.com/");

and after performing run on the file I am getting exception like ...

org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH.

Make sure firefox is installed. OS appears to be: MAC

System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.8',

java.version: '1.6.0_29'

Driver info: driver.version: FirefoxDriver

Can anyone help me out regarding how and where to give path to firefoxprofile()

8
WebDriver cannot find path to binary file of Firefox. Are you sure Firefox is installed?p0deje
@p0deje : Of course it is !! and also i am using it now ...Aspirant

8 Answers

18
votes

I believe you have several options:

Either specify the folder (in which your Firefox binary is) in your PATH system variable - here's how.

Or call

WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File("path/to/your/firefox.exe")), profile);
11
votes

For Mac, if you installed FireFox via brew cask, just symbolic link it to /Applications.

cd /Applications
ln -s /Users/<your-username>/Applications/Firefox.app Firefox.app

This worked for me.

3
votes

In my case I need to move Firefox.app from /Users/username/Applications to /Applications

3
votes

For Mac:

  1. Use selenium jar 2.44.0 (make sure selenium server jar is 2.44.0)
  2. firefox version 33 (https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/33.0/mac/en-US/)
  3. In terminal of Mac, Use this command to create profile for firefox : "/Applications/Firefox.app/Contents/MacOS/firefox-bin" -p

    1. while creating the profile, you would see the path of profile with .default, - make note of this for entering the same in code for profile path.

    2. Code would look like this:

String profilePath="/Users/admin/Library/ApplicationSupport/Firefox/Profiles/4duhjf19.default";

                System.out.println("profilePath: "+profilePath);
                File checkProfile = new File(profilePath);
                File[] allFolder = checkProfile.listFiles();
                for (int i = 0; i < allFolder.length; i++) {

                    if (allFolder[i].getName().endsWith(".default")) {
                        profilePath = profilePath + allFolder[i].getName();
                        break;
                    }
                }
FirefoxProfile firefoxprofile1 = new FirefoxProfile(new File(
                        profilePath));
                System.out.println("profile path : " + firefoxprofile1);
                driver = new FirefoxDriver(firefoxprofile1);
                System.out.println("webdriver FF");
                driver.manage().deleteAllCookies();
1
votes

i met this problem before, it's very easy to fix it.

on Windows, modify the environment variables , add the firefox path to the PATH variable.

it's should be similar on Mac, just export PATH=/my/firefox/path/bin:$PATH in your profile file.

1
votes

I'm not sure about on a Mac, but on Windows I resolved this issue.

Make sure you are using the 32 bit version of nunit. Firefox is a 32 bit browser.

I have a 64 bit windows OS, but Firefox is a 32 bit browser. I was trying to use the 64 bit version of nunit, which was giving this "Cannot fine firefox binary in PATH" error. I resolved this by using the 32 bit version of nunit. Basically, there are two exe files in the nunit folder, nunit.exe and nunit-x86.exe. If you are getting this "Cannot fine firefox binary in PATH" error, most likely you need to use the 32 bit version of nunit - the Nunit-x86.exe.

1
votes

On Mac OS X, I was receiving a WebDriver error like "Could not find Firefox binary (os=macosx)" when attempting to run a script.

I discovered that my problem was that a renamed my Firefox app to "Firefox 22". The WebDriver stuff expected just "Firefox".

0
votes

This kind of issue obtained because of selenium web driver fail to find the .exe files of Firefox. Please check whether C:\Program Files (x86)\Mozilla Firefox you have exe file in the location and don’t forget to set environment variable having the java jdk path. Source:- http://www.tech4crack.com/solved-cannot-find-firefox-binary-in-path/