selenium - PhantomJS 无法访问自签名 HTTPS 页面 Codeception

标签 selenium ssl phantomjs codeception

我目前正在使用以下工具进行验收测试:

  • 代码接收
  • Selenium Webdriver
  • PhantomJS (作为 headless 浏览器幽灵)

我的问题是访问自签名 (https) 页面时我的测试失败

我尝试过的:

  1. phantomjs --webdriver=5555 --ignore-ssl-errors=true --ssl-protocol=any
  2. 在我的 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 中的答案会更好。谢谢

最佳答案

如果出现此问题,我们会找出原因。这是因为我同时运行了 SeleniumphantomJS。 (我从一些教程中得到了这个想法。)

我在做

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/

相关文章:

javascript - Phantomjs/Casperjs 现在不工作网站检测机器人

java - Selenium .ElementNotVisibleException : Element is not currently visible JAVA

python - 如何导航上下文菜单(Selenium、Python)

javascript - Laravel Dusk - 执行 javascript 脚本并等待 Promise 被解析以返回值

Python+LDAP+SSL

java - 用于相互认证的 keystore /信任库中必须包含什么?

node.js - Facebook 无法抓取我的安全网址 (Nginx)

node.js - Casper --proxy 不起作用

testing - 使用 Laika 和 PhantomJS 进行集成测试

python - 如何从表中创建行列表