我需要为HTTPS实现Headless Browser(验证证书)。为此,我需要编写额外的代码行。
我已经为浏览器HTTP编写了它并且工作正常。
public class Headless {
public static void main(String[] args)
{
File src=new File("C:\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path",src.getAbsolutePath());
WebDriver driver=new PhantomJSDriver();
driver.get("https://www.google.co.in/");
System.out.println(driver.getTitle());
}
}
我谷歌并获得一些信息: -
phantomjs --ignore-ssl-errors=yes;
答案 0 :(得分:0)
DesiredCapabilities dcap = new DesiredCapabilities();
String[] phantomArgs = new String[] {
"--ssl-protocol=any",
"--ignore-ssl-errors=true"
};
dcap.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
PhantomJSDriver driver = new PhantomJSDriver(dcap);
您可以在此链接上详细了解命令行选项:Command Line Interface | PhantomJS