chromeOptions - “ignore-certificate-errors”没有消除err_cert_authority_invalid错误

时间:2017-01-10 10:44:00

标签: selenium-webdriver appium

我使用的是appium 1.5.3版和Android Emulator 7.1.1。

我启动android驱动程序并设置chrome选项,因为测试中的应用程序没有有效的ssl证书:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 0);
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
capabilities.setCapability(MobileCapabilityType.VERSION, "XXX");                          
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "XXX");                
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1");
capabilities.setCapability(MobileCapabilityType.ACCEPT_SSL_CERTS, true);

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("ignore-certificate-errors");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

wd = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities);

但是,尽管将ignore-certificate-errors设置为true,我最终会在Chrome浏览器上出现以下错误:

enter image description here

  • 我还需要设置其他功能吗?

1 个答案:

答案 0 :(得分:3)

标记--ignore-certificate-errors已添加到坏标记列表中,因为它降低了浏览器的安全性。要禁用这些不受支持的标志,您应该添加--test-type选项,如下所示:

options.addArguments("--test-type");

更多信息here