8

Im currently making an acceptance test with the following tools:

  • Codeception
  • Selenium Webdriver
  • PhantomJS (as headless browser ghost)

My problem is My Tests fail when visiting a self-signed (https) page

What I've tried:

  1. phantomjs --webdriver=5555 --ignore-ssl-errors=true --ssl-protocol=any
  2. Adding this in capabilities phantomjs.cli.args: ["--ignore-ssl-errors=true"] in my acceptance.suit.yml

So far these options doesnt give me any luck.

Here is my acceptance.suit.yml file

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"]

UPDATE

This error shows up [ModuleException] WebDriver: Current url is blank, no page was opened

I don't know why this error happens since I've indicated a page. Here is a sample of my test

public function tryToTestThis(AcceptanceTester $I)
{
    $I->wantTo('Test this function');
    $I->amOnPage('/mypage/');
    $I->see('This text');
}

An answer in Codeception would be preferable. Thanks

Sergei Voronezhskii
  • 2,184
  • 19
  • 32
Þaw
  • 2,047
  • 4
  • 22
  • 39
  • Could you please elaborate more on what is happening? Any errors, how does the test fail? Thanks. – alecxe Mar 11 '16 at 18:06
  • @alecxe Hi I updated my post. It says `[ModuleException] WebDriver: Current url is blank, no page was opened` – Þaw Mar 14 '16 at 05:45
  • I was able to replicate your error and running phantomjs with --ignore-ssl-errors=true enabled my test to pass. Only difference is I'm not using http_proxy and http_proxy_port, have you checked your proxy? – MajicBob Mar 16 '16 at 00:07
  • @MajicBob Yes I've made sure my proxy is right. What Im not sure is, if its the right way to set the `http_proxy` codeception doesnt show any example that is setting an `http_proxy` and `http_proxy_port` – Þaw Mar 17 '16 at 05:20
  • @Þaw Yeah the docs aren't great there and I haven't used it with a proxy before. The only other things I can think of are to make sure you are seeing the request come in to your proxy and try moving the 2 settings to the modules: section instead of env. – MajicBob Mar 17 '16 at 05:29
  • When you have a proxy in the mix, your proxy has to accept the certificate on your behave first. So The problem may be with your proxy. How are you managing your proxy? – Brian S. Mar 17 '16 at 20:12

1 Answers1

1

We figured out the cause if this problem. It was because I was running Selenium and phantomJS at the same time. (I got this idea from some tutorial.)

I was doing

java -jar selenium.jar

then I do this since it causes an error running phantomjs at port 4444 (Obviously selenium is using it) I use port 5555 instead.

phantomjs --webdriver=5555 --ignore-ssl-errors=true --ssl-protocol=any

Note: Everything works fine if not involved with https / ssl self-signed pages.

We think that codeception prioritize port 4444 and disregarding any option indicated in my phantomjs i.e. --ignore-ssl-errors=true --ssl-protocol=any thats why in fails to visit https/self-signed pages.

So basically, the fix was just running phantomjs alone without selenium.

phantomjs --webdriver=4444 --ignore-ssl-errors=true --ssl-protocol=any

Thank you

Þaw
  • 2,047
  • 4
  • 22
  • 39