通过驱动程序ChromeOptions和DesiredCapabilities?

编程入门 行业动态 更新时间:2024-10-09 03:26:40
本文介绍了通过驱动程序ChromeOptions和DesiredCapabilities?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

新的Google chrome更新导致浏览器中出现此消息:您使用的是不受支持的命令行标志:-ignore-certificate-errors.稳定性和安全性将受到损害."

The new Google chrome update causes this message in the browser "You are using an unsupported command-line flag: --ignore-certificate-errors. Stability and security will suffer."

根据我对硒错误报告的了解,临时解决方案是使用

From what I read on selenium bug reports, the temporary solution is to start webdriver with

options.AddArgument("test-type")

在创建驱动程序时,我已经在传递DesiredCapabilities了.如何将ChromeOptions和DesiredCapabilities都传递给驱动程序?

I was already passing DesiredCapabilities when creating the driver. How can I pass both ChromeOptions and DesiredCapabilities to the driver?

DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability("chrome.switches", Arrays.asList("--incognito")); ChromeOptions options = new ChromeOptions(); options.addArguments("test-type"); WebDriver driver = new ChromeDriver(capabilities);

推荐答案

我正在解决相同的问题,终于破解了.基本上,可以将ChromeOptions添加到DesiredCapabilities,然后使用DesiredCapabilities创建驱动程序.一旦我尝试过,它就摆脱了旗帜.无论如何,这是代码:

I was fighting the same problem, and I finally cracked it. Basically, you can add ChromeOptions to DesiredCapabilities then create the driver with the DesiredCapabilities. Once I tried it, it got rid of the banner. Anyway, here is the code:

DesiredCapabilities capabilities = DesiredCapabilities.chrome(); ChromeOptions options = new ChromeOptions(); options.addArguments("test-type"); capabilities.setCapability("chrome.binary", "<Path to binary>"); capabilities.setCapability(ChromeOptions.CAPABILITY, options); webDriver = new ChromeDriver(capabilities);

更多推荐

通过驱动程序ChromeOptions和DesiredCapabilities?

本文发布于:2023-11-27 16:19:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638718.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:驱动程序   ChromeOptions   DesiredCapabilities

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!