I decided to write this article after someone asked about browser profiles with Selenium in the IRC channel.
With Selenium we can specify a particular browser profile when instantiating our driver so if you happen to have specific browser setup requirements such as Firefox with certain plugins installed we can tell the driver to use this.
To begin with we will want to setup up our profile to be used. In this example we will use Firefox and use the Firefox profile manager.
To access this run “firefox -p” from Run.
Which will load up the profile manager, here we will create a new profile and call it ‘QAToolsProfile’ – for this example we will choose the save folder as ‘Browser Profile’ on the desktop.
Next, start up firefox and add in the tools required for your new profile, I am going to add a tool called REST Client.
Right then! We now have a customised browser profile to call in our code.
Calling the Profile
As you might expect this is relatively easy as we just need to pass in the location of the profile which we dumped on the desktop:
profileDir = @"C:\Users\user.name\Desktop\BrowserProfile";
FirefoxProfile profile = new FirefoxProfile(profileDir);
Driver = new FirefoxDriver(profile);
If we now say to a test to navigate to “chrome:/
You can find more information on Browser Profiles with Firefox here.