Skip to content

andgineer/e2e-tests

Repository files navigation

Github CI Status

End-to-end pytest with Selenium Grid in Docker Compose

A robust end-to-end testing setup that exercises Chrome, Firefox, and Microsoft Edge using headless browsers and Selenium Grid in Docker Compose.

Includes rich test reporting powered by Allure.

For detailed implementation insights, check out my blog post.

Test Reporting

This framework generates comprehensive Allure reports:

Allure Report Example

Reports are automatically published to GitHub Pages: Latest test results.

Getting Started

Setup

Launch the Allure server and Selenium Grid:

docker compose up -d

The Allure reports will be available at http://localhost:8800, and the Selenium Grid console at http://localhost:4444/ui/.

The Selenium Grid is started automatically by the tests (see setup_selenium_grid() in conftest.py), but manually launching it in the background with docker compose makes tests faster since they don't need to start and stop the Grid for each test run.

Multiple Project Setup

When using Selenium Grid across multiple projects, you may encounter port conflicts:

Bind for 0.0.0.0:4442 failed: port is already allocated

This happens if the Selenium Grid is already running.

In such cases, start Docker Compose without Selenium Grid:

docker compose up -d --scale hub=0

Running Tests

Prerequisites

  1. Install dependencies:

    . ./activate.sh

  2. Run tests and generate reports:

    scripts/test.sh

Tests store results in the allure-results folder, which is mounted to the Allure reporter Docker container.

Tests run in parallel across Chrome, Firefox, and Microsoft Edge via the session-scoped pytest fixture browser.

Testing Custom URLs

The framework supports testing any web application via the --host parameter. For example:

scripts/test.sh --host=https://google.com

The --host parameter is implemented using pytest's hook pytest_addoption in conftest.py.

Note: The Google example above will fail because it expects to find the word "Python" on the main page.

About

End-to-End pytest with Selenium Grid in docker compose

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published