gpt4 book ai didi

javascript - 在节点的 selenium-webdriver 中为 phantomjs 设置 service_args

转载 作者:行者123 更新时间:2023-11-29 17:06:11 24 4
gpt4 key购买 nike

我需要能够使用以下参数运行 phantomjs:

--ignore-ssl-errors=true

我正在测试的页面使用自签名证书,所以我需要 arg 来打开页面。我正在尝试使用以下代码片段在 webdriver 中传递 arg:

capabilities = webdriver.Capabilities.phantomjs();
capabilities.set('service_args', '--ignore-ssl-errors=true');
driver = new webdriver.Builder().
withCapabilities(capabilities).
build();

传递 service_args 的方式是否正确?我真的希望不会,因为我无法加载我的测试页。我可以通过运行打开页面:

phantomjs --ignore-ssl-errors=true myTest.js

这是 myTest.js 中的代码

var page = new WebPage();
page.open('https://my.somefaketestpage.com/', function (status) {
just_wait();
});

function just_wait() {
setTimeout(function() {
page.render('screenshot.png');
phantom.exit();
}, 2000);
}

最佳答案

正确答案是:

caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--web-security=no", "--ignore-ssl-errors=yes"});
driver = new PhantomJSDriver(caps);

记录在此处:https://github.com/detro/ghostdriver/issues/233

关于javascript - 在节点的 selenium-webdriver 中为 phantomjs 设置 service_args,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24522899/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com