How to change user agent in Firefox by selenium webdriver

In this article , we will see the function to change user agent of Firefox using selenium webdriver. I am using c# with vs 2010.
From my administrating Firefox post, we know that we can change preferences. I have another post describing different user agent(how to change user agent in jmeter) . So, lets change the agent from webdriver so that when ever we need we can use Firefox to change its agent to test different behavior of a web application.

First declare a Firefox profile. Then change general.useragent.override with a value(desire user agent string, any from here or here )

public static FirefoxProfile myFireProfile = new FirefoxProfile();

myFireProfile.SetPreference("general.useragent.override", "our_string");

public IWebDriver driver= new FirefoxDriver(myFireProfile);

So, our Firefox driver initializes with new user agent .

Thanks...:) 

No comments:

Post a Comment