我目前正在使用以下工具进行验收测试:
- 代码接收
- Selenium Webdriver
- PhantomJS (作为 headless 浏览器幽灵)
我的问题是访问自签名 (https) 页面时我的测试失败
我尝试过的:
phantomjs --webdriver=5555 --ignore-ssl-errors=true --ssl-protocol=any
- 在我的 acceptance.suit.yml 中添加此功能
phantomjs.cli.args: ["--ignore-ssl-errors=true"]
到目前为止,这些选项没有给我任何运气。
这是我的 acceptance.suit.yml
文件
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
config:
WebDriver:
url: https://myproject.com
browser: firefox
capabilities:
unexpectedAlertBehaviour: 'accept'
env:
phantom:
modules:
enabled:
- WebDriver
config:
WebDriver:
url: https://myproject.com
http_proxy: 192.1.1.1
http_proxy_port: 3000
browser: phantomjs
capabilities:
phantomjs.cli.args: ["--ignore-ssl-errors=true"]
更新
出现此错误 [ModuleException] WebDriver: Current url is blank, no page was opened
我不知道为什么会出现这个错误,因为我已经指出了一个页面。这是我的测试示例
public function tryToTestThis(AcceptanceTester $I)
{
$I->wantTo('Test this function');
$I->amOnPage('/mypage/');
$I->see('This text');
}
Codeception 中的答案会更好。谢谢
最佳答案
如果出现此问题,我们会找出原因。这是因为我同时运行了 Selenium
和 phantomJS
。 (我从一些教程中得到了这个想法。)
我在做
java -jar selenium.jar
然后我这样做,因为它会导致在端口 4444 运行 phantomjs 时出错(显然 selenium 正在使用它)我改用端口 5555。
phantomjs --webdriver=5555 --ignore-ssl-errors=true --ssl-protocol=any
注意:如果不涉及 https/ssl 自签名页面,一切正常。
我们认为 codeception
优先考虑端口 4444 并忽略我的 phantomjs 中指示的任何选项,即 --ignore-ssl-errors=true --ssl-protocol=any
就是这样为什么访问https/自签名页面失败。
所以基本上,修复只是在没有 selenium 的情况下单独运行 phantomjs。
phantomjs --webdriver=4444 --ignore-ssl-errors=true --ssl-protocol=any
谢谢
关于selenium - PhantomJS 无法访问自签名 HTTPS 页面 Codeception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35863865/