5

I have somewhere an error in setting the Webdriver for my codeception and just can't figure it out.

when starting with

docker-compose run --rm codeception run

it finds the acceptance tests, and even reads the $I->wantTo

but then throws an error:

[ConnectionException] Can't connect to Webdriver at http://127.0.0.1:4444/wd/hub. Please make sure that Selenium Server or PhantomJS is running.

my acceptance.suite.yml is the following and I already tried replacing the url with chrome, nginx-web, the ip of the actual server (which does not make sense, but I really don't know what else to put in there)

actor: AcceptanceTester
modules:
    enabled:
        # selenium webdriver
        - WebDriver:
            url: 'http://localhost/'
            browser: chrome

        - \Helper\Acceptance

my docker-compose.yml. I set the volumes in an additionl override

version: '2'
services:

  codeception:
    image: codeception/codeception:2.3.5
    depends_on:
      - nginx-web
      - php-web
      - chrome

  nginx-web:
    image:
      nginxext:0.5.6
    depends_on:
      - php-web
    expose:
      - 80

  php-web:
    image:
      phpext:0.7.0
    expose:
      - 9000

  # https://github.com/SeleniumHQ/docker-selenium
  chrome:
    image: selenium/standalone-chrome-debug:3.7.1
    ports:
      - 4444
      - 5900

Any ideas what I am doing wrong?

1 Answer 1

8

I finally found it. Given the various descriptions on the net using just url, I thought that I am setting the host also with the url. But you actually need to set the host and the url independently. So the solution is to add the service name of the selenium browser together with host.

        - WebDriver:
            url: http://localhost/      # url of app
            browser: chrome
            host: chrome                # selenium server host, default 127.0.0.1
#            port: 4444                 # selenium server port, default 4444
#            window_size: maximize      # or 640x480
Sign up to request clarification or add additional context in comments.

4 Comments

Is that correct that host value is chrome? I thinks it should localhost instead.
Yes, it is correct for my environment. I am running it in a docker container and in the docker-compose.yml I call the service "chrome".
Aah, I see. (y)
I had to set url to chrome (or whatever the container name is) to make it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.