通过驱动程序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."
根据我对硒错误报告的了解,临时解决方案是使用
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屋!