Sitam Jana
Sitam Jana

Reputation: 3129

Get Firefox Profile Name at Runtime and Set preferrence

I have a scenario to handle where I am opening Firefox browser using Selenium Webdriver and each time it opens up a new profile. Code is written below:

WebDriver driver = new FirefoxDriver();

Each time it opens up a new profile which is something like : anonymous8958670169066009851webdriver-profile and profile name changes every time WebDriver opens up a Firefox browser. My intention is to get the profile name at runtime and set some preferences on it like handling unresponsive JS alert etc. Basically flow will look like something below:

WebDriver driver = new FirefoxDriver();
<Write some code here to get Firefox profile name>
<Set profile settings like **profile.setPreference("extensions.firebug.currentVersion", "1.8.1");>

Please help me in the second step i.e. Write some code here to get Firefox profile name if anyone already achieved something similar before.

Upvotes: 0

Views: 619

Answers (1)

JimEvans
JimEvans

Reputation: 27496

You're approaching the problem backward. The correct thing to do is to create the FirefoxProfile object yourself, and using it in the constructor to the FirefoxDriver. The code would look something like this:

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("extensions.firebug.currentVersion", "1.8.1");
WebDriver driver = new FirefoxDriver(profile);

Upvotes: 1

Related Questions