How do you create a browser profile for Selenium's PhantomJS/GhostDriver?

≯℡__Kan透↙ 提交于 2019-12-01 15:22:23
luksch

The closest you can get with phantomjs is to use the driver capabilities:

DesiredCapabilities caps = DesiredCapabilities.phantomjs();
caps.setCapability( "phantomjs.page.settings.userAgent", "Mozilla");
Set<String> cliArgs = new HashSet<>();
cliArgs.add("--ignore-ssl-errors=true");
cliArgs.add("--ssl-protocol=any");
cliArgs.add("--web-security=false");
caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgs);
driver = new PhantomJSDriver(caps);

However, you notice that there are no configuration options for automatic downloading, since phantomjs does not support this. It is anyway not a very good idea to use selenium for testing of downloads. I did answer another related question earlier in which I point to an article about this and why you should not do it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!