Not able to configure Selenium Chrome to work with Codeception

Viewed 140

I am trying to configure Selenium with Chrome to work with Codeception.

This is my docker-compose.yml file

version: "3.5"

services:
  mysql:
    image: mysql:8.0
    container_name: my-board-mysql
    working_dir: /application
    command: --default-authentication-plugin=mysql_native_password
    hostname: mysql
    volumes:
    - mysql_storage:/var/lib/mysql
    env_file:
    - .env
    networks:
    - backend
    ports:
    - "9834:3306"

  webserver:
    build:
      dockerfile: ./docker/nginx/Dockerfile
      context: .
    container_name: my-board-server
    working_dir: /application
    depends_on:
    - php-fpm
    networks:
    - backend
    volumes:
    - .:/application
    - ./docker/nginx/nginx_local.conf:/etc/nginx/conf.d/default.conf
    ports:
    - "8924:80"

  php-fpm:
    build:
      dockerfile: docker/php-fpm/Dockerfile-local
      context: .
    container_name: my-php-fpm
    depends_on:
    - mysql
    volumes:
    - .:/application
    - ./docker/php-fpm/php-ini-overrides.ini:/etc/php/7.3/fpm/conf.d/99-overrides.ini
    networks:
    - backend
    
  chrome:    
    image: selenium/standalone-chrome:latest
    ports:
      - 4444:4444
    container_name: chrome
    networks:
      - backend

networks:
  backend:
    driver: bridge
    ipam:
      config:
      - subnet: 172.24.0.0/22

volumes:
  mysql_storage:

And this is my Codeception configuration file: acceptance.suite.yml:

actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: 'http://localhost:8924'
            browser: chrome
        - \App\Tests\Helper\Acceptance

When I navigate to http://localhost:8924 I can see the site, and when I navigate to http://localhost:4444 I can see Selenium page.

When I run Codeception using vendor/bin/codecept run --steps, I can see this failure:

 [Facebook\WebDriver\Exception\UnknownErrorException] unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: chrome=89.0.4389.82)  

It seems that it is not possible to open localhost from webserver which is under docker. Any advice how can I fix this?

I am running this on Mac if it matters.

0 Answers
Related