c# - Selenium Chrome C# 更改现有 Web 驱动程序上的用户代理而不创建新驱动程序?

标签 c# google-chrome selenium selenium-webdriver user-agent

我使用以下代码创建带有移动用户代理的 Chrome 驱动程序:

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);

我首先使用浏览器附带的标准默认用户代理,但随后我必须切换到移动用户代理。是否可以在不 Quit() 普通驱动程序并使用上面所示的代码重新创建一个新驱动程序的情况下完成此操作?

最佳答案

我不相信,我们必须创建一个新的驱动程序。

关于c# - Selenium Chrome C# 更改现有 Web 驱动程序上的用户代理而不创建新驱动程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22110056/

相关文章:

c# - string.Format "C"(货币)返回字符串 "C"而不是格式化文本

jquery - 网站在 Mac Safari、Firefox、Chrome 上预览效果很好,但在 PC 浏览器上只显示正文

javascript - OSS Chrome 扩展 - 我应该 checkin pem 文件吗?

java - Selenium 网络驱动程序错误

java - 悬停属性的 Selen 测试

c# - 通缉 : Cuckoo Hashing in C#

c# - 如何将参数传递给 DbMigration.Sql() 方法

python - 属性错误: 'WebElement' object has no attribute 'get_text' error extracting the text between the starting and ending tag using Selenium Python

c# - "internal class"不是在一个库中编译,而是在一个新的类库中工作

css - 在 2560x1600 像素的大显示屏上,Chrome 中的字体较小