通过驱动程序 ChromeOptions 和 DesiredCapabilities? [英] Pass driver ChromeOptions and 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."
根据我在 selenium 错误报告中阅读的内容,临时解决方案是使用
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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!