同一网站有两个实例,唯一不同的是,一个使用有效,另一个使用无效HTTPS/SSL certification
。我尝试在无头ChromeDriver 2.31
中打开它们,发现它只在有效SSL
认证的情况下打开网站。
<chromepath> --headless --remote-debugging-port=9101 --disable-gpu <siteurl>
上面的代码会打开一个网站https://chrome-devtools-frontend.appspot.com/serve_file/identification_number,其中包含来自指定网站的预览。
我使用它来忽略证书问题,但我在ChromeDriver
中获得了此网站的相同空白页。
caps.setCapability("chrome.switches", Arrays.asList("--ignore-certificate-errors"));
答案 0 :(得分:3)
迟到聚会,也许对某人有用,下面的参数对我有用。
acceptInsecureCerts: true
答案 1 :(得分:1)
您可以使用DesiredCapabilities
DesiredCapabilities handlSSLErr = DesiredCapabilities.chrome ();
handlSSLErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, false);
WebDriver driver = new ChromeDriver (handlSSLErr);
尝试一下,可能对你有帮助。
第二种方式:
System.setProperty("webdriver.chrome.driver", "E:\\software and tools\\chromedriver_win32\\chromedriver.exe");
ChromeOptions option= new ChromeOptions();
option.addArguments("headless");
option.addArguments("ignore-certificate-errors");
WebDriver d=new ChromeDriver(option);
//d.get("http://expired.badssl.com/");
d.get("https://expired.badssl.com/");