I’m wondering if I can change the user agent profile on the fly, without creating a new
instance of the ForeFoxDriver? I have the following code, which I can pass in the user agent for iphone or ipad, etc.. it works fine, but i’m having to create a new instance for each test which is slow as it opens/closes the browser. E.g. After doing my tests with iPhone user agent, I’d like to switch the profile to Android user agent or iPad user agent, does the driver get the option to change this without needing to create a new instance?
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("general.useragent.override","some user agent, like iphone or iPad");
WebDriver driver = new FirefoxDriver(profile);
// do some tests
// set profile to new user agent
// profile.setPreference("general.useragent.override","some android user agent");
// can i now set the driver to the new profile here and perform more tests on this same instance of the driver?
RemoteWebdriver (parent class of FirefoxDriver) updates the capabilities map only when the session is starting (in the constructor). Unfortunately we can’t modify it elsewhere. I think it is a very good idea.