Røye
Røye

Reputation: 1154

How can I configure the firefox binary location in Protractor?

I am successfully running Protractor tests with Chrome, specifying the path to my chrome binary using the following section in my Protractor configuration:

capabilities: {
// You can use other browsers
// like firefox, phantoms, safari, IE
'browserName': 'chrome',
"chromeOptions": {
  binary: 'C:/BuildSoftware/Chrome/Application/chrome.exe',
}

This works.

My Firefox is also installed in a non-standard location.

Is there an equivalent way to specify the binary for Firefox in the protractor config?

Upvotes: 8

Views: 12299

Answers (5)

Sameera De Silva
Sameera De Silva

Reputation: 1980

To elaborate Monkpit's answer which is correct .Below code is worked for me , verified and tested in protractor v 5.4.2 . Only thing is needed to open the cmd via admin mode to avoid the permission error since I installed Firefox in program files.

 capabilities: {
      browserName: 'firefox',
      'moz:firefoxOptions': {
            args: ['--verbose'],
            binary: 'C:/Program Files/Mozilla Firefox/firefox.exe'
       //Need to start cmd via admin mode to avoid permission error
        }
},   
    Full code 

exports.config = {
  framework: 'jasmine',
  directConnect: false, //Start protractor without start the selenium server using webdriver-manager start. default value is fales
  //This is  only for chrome and firefox and use drivers instead of selenium server

  capabilities: {
      browserName: 'firefox',
      'moz:firefoxOptions': {
            args: ['--verbose'],
            binary: 'C:/Program Files/Mozilla Firefox/firefox.exe'
       //Need to start cmd via admin mode to avoid permission error
        }
},   
    //set to true So each spec will be executed in own browser instance. default value is false
    //restartBrowserBetweenTests: true,
     jasmineNodeOpts: {
    //Jasmine provides only one timeout option  timeout in milliseconds don't add ;
    defaultTimeoutInterval: 180000
     },

  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['src/com/sam/scriptjs/iframes.spec.js']

}

Upvotes: 0

Kyle Pittman
Kyle Pittman

Reputation: 3077

It's 2018 and it appears you can set a specific binary argument within the 'moz:firefoxOptions' section of the capabilities like so:

capabilities: {
    browserName: 'firefox',
    'moz:firefoxOptions': {
        args: [...Your args here...],
        binary: '/Path/To/Custom/firefox'
    }
}

Disclaimer: I ran this with directConnect: true in my protractor config also. I'm not sure if it works if you're passing the command to the Selenium server.

Reference: https://github.com/mozilla/geckodriver/blob/master/README.md#mozfirefoxoptions

Upvotes: 4

Gonzalo Matheu
Gonzalo Matheu

Reputation: 10064

I added my custom binary location to PATH variable.

export PATH="/custom-firefox-location:$PATH"

That makes my custom firefox version to be available during the session and when running protractor it uses that.

Upvotes: 1

6220119
6220119

Reputation: 809

UPDATED: See newer answer below: https://stackoverflow.com/a/28313583/800699

It seems you have to start the Selenium Server by yourself with custom arguments for firefox driver. See Protractor test is not starting on Firefox

More options for firefox driver (including custom firefox binary location) can be found here: https://code.google.com/p/selenium/wiki/FirefoxDriver

P/S: Browsing the firefox driver source reveals more light: https://code.google.com/p/selenium/source/browse/javascript/node/selenium-webdriver/firefox/index.js

You can try adding:

"browserName": "firefox",
"firefox_binary": "path/to/custom/firefox",
"binary_": "path/to/custom/firefox"

Upvotes: 12

P.T.
P.T.

Reputation: 25177

Protractor now supports setting the firefoxPath directly in the configuration file, when using "direct connect" (i.e., without a selenium server). See the reference config file:

https://github.com/angular/protractor/blob/master/docs/referenceConf.js#L67

Add firefoxPath to the config file, at the top-level. It is a string that should be the path to your firefox binary. You will also need directConnect: true in the config.

For more details (handy to see all the doc that changed at once) check out the change that added this support (in Oct 2014).

Upvotes: 6

Related Questions