I don't believe so, we had to create a new driver.
Selenium Chrome C# change user agent on existing web driver without creating a new one?
-
18-10-2022 - |
Question
I am using the following code to create a Chrome driver with a mobile user agent:
ChromeOptions options = new ChromeOptions();
options.AddArgument("--user-agent=Mozilla/5.0 (Linux; Android 4.1.2; SHV-E250S Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.82 Mobile Safari/537.36");
IWebDriver mobileDriver = new ChromeDriver(@"PATH-TO-WEB-DRIVER", options);
I am using the standard, default user agent that comes with the browser at first, but I must then switch to a mobile user agent. Is it possible to do this without Quit()
ing the normal driver and recreating a new one with the code shown above?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow