how to change user agent in selenium with .net
Example UA (You may need Google yourself to find the ones suit your purpose):
Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25
C# Firefox:
FirefoxProfile profile = new FirefoxProfile();profile.SetPreference("general.useragent.override", "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25");IWebDriver driver = new FirefoxDriver(profile);
C# Chrome:
ChromeOptions options = new ChromeOptions();options.AddArgument("--user-agent=Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25");IWebDriver driver = new ChromeDriver(options);
C# PhantomJS (untested code):
PhantomJSOptions options = new PhantomJSOptions();options.AddAdditionalCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25");IWebDriver driver = new PhantomJSDriver(options);
C# IE: Sorry, I don't think this is possible natively from Selenium.
Further reading: Set user agent using Selenium WebDriver C# and Ruby
In c#:
public static FirefoxProfile myFireProfile = new FirefoxProfile();myFireProfile.SetPreference("general.useragent.override", "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10");public IWebDriver driver= new FirefoxDriver(myFireProfile);