Som
Som

Reputation: 4718

How to set the firefox profile at the node end in remote webdriver/grid configuration

It is always suggested to set the firefox profile in DesiredCapabilities and pass that through the wire ,where the hub is running . Like below

DesiredCapabilities caps = DesiredCapabilities.firefox();

    FirefoxProfile profile=new FirefoxProfile(new File("Local Path to firefox profile folder"));
    caps.setCapability(FirefoxDriver.PROFILE, profile);

URL url = new URL("http://localhost:4444/wd/hub");      
WebDriver driver= new RemoteWebDriver(url,caps );

But sending the huge 87-90 mb profile info to hub over http ,for each selenium test case slowing down the test case execution .

I have tried configuring the grid node with "Dwebdriver.firefox.profile=E:\\Firefox_Profile_Location":"", property in json node config file like below.

{
"configuration":
{
.//Other Settings
.//Other Settings
.//Other Settings
"Dwebdriver.firefox.profile=E:\\Firefox_Profile_Location":"",
"maxSession":7,
"registerCycle":5000,
"register":true
},
"capabilities":
[

{"browserName":"firefox",
"seleniumProtocol":"WebDriver",
"maxInstances":5,
"platform":"VISTA"
}
]
}

But running with the above configuration is throwing below error .

WebDriverException: Firefox profile 'E:\Firefox_Profile_Location' named in system property 'webdriver.firefox.profile' not found

Advanced thanks for any help on how to configure the firefox profile from the node side .

Upvotes: 13

Views: 4266

Answers (2)

user1207289
user1207289

Reputation: 3253

I think you'll have to use firefox profile name and not the location.

"webdriver.firefox.profile":"default"

Have a look at this and this and this

If you want know how to create a profile follow this and this

Upvotes: 3

Florent B.
Florent B.

Reputation: 42518

You need to provide the profile in the capabilities object as a base64 encoded zip:

var fs = require('fs');
capabilities: [
  {
    browserName: 'firefox',
    seleniumProtocol: 'WebDriver',
    maxInstances: 5,
    platform: 'VISTA',
    firefox_profile: new Buffer(fs.readFileSync("./profile.zip")).toString('base64')
  }
]

Moreover Firefox creates the missing files for a given profile. So you should keep just the necessary files in the profile depending on your needs:

Preferences:  user.js
Passwords:    key3.db
              logins.json
Cookies:      cookies.sqlite
Certificate:  cert8.sqlite
Extensions:   extensions/

Upvotes: 3

Related Questions