1
votes

Could you help me. I use Codeception with Webdriver for my project

Codeception PHP Testing Framework v4.1.3 Powered by PHPUnit 9.0.1 by Sebastian Bergmann and contributors.

acceptance.suite.yaml:

actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
              url: 'https://localhost:8888'
              browser: chrome
              clear_cookies: true
              port: 4444
              capabilities:
                  browser: chrome
                  goog:chromeOptions:
                      w3c: false

Docker:

docker run -p 4444:4444 -v /dev/shm:/dev/shm --rm selenium/standalone-chrome

I can see my localhost in Browser. If i instead localhost:8888 use external site all right. But by testing i have "This site can't be reached. localhost refused to connect".
Test is very simple:

<?php

class FirstCest
{
    public function tryToTest(AcceptanceTester $I)
    {
        $I->amOnPage('/');
        $I->wait(5);        
        $I->makeScreenshot();
        I->see('Home');
    }
}

thanks in advance

1
looks like docker issue to me. - Naktibalda

1 Answers

0
votes

You need to make a URL host and port tweak to your acceptance.suite.yml since you are using a dockerized Selenium container to view your local website:

actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
              url: 'https://host.docker.internal:8888'

Note: If you are using Docker on Linux, your URL should instead be: 'https://172.17.0.1:8888'

You will then want to open that port in your dockerized Selenium container:

docker run \
-p 4444:4444 \
-p 8888:8888 \ # I'm new!
-v /dev/shm:/dev/shm \
--rm selenium/standalone-chrome