Automated Tester

.science

This content shows Simple View

Browser Profiles

Browser Profiles with Selenium

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.

Setup

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.

profiles1

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.

profiles2

profiles3

Next, start up firefox and add in the tools required for your new profile, I am going to add a tool called REST Client.

profiles4

profiles5

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:

private static void SetupFirefoxDriver()
{
string profileDir;

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://restclient/content/restclient.html” we can automate the browser plugin. In this instance we can perform some API checks with RESTClient’s user interface. If we did not specify the profile then Firefox would load up with no extra frills.

profiles6

You can find more information on Browser Profiles with Firefox here.




top