Skip to content

This repository contains a test automation project using PyTest and Playwright. We use the ‘test cases as code’ approach and store test reports in a database. We also generate reports in Allure.

License

Notifications You must be signed in to change notification settings

ZhikharevAl/db_web_test_automation

Repository files navigation

🎭UI Automation with Python and Playwright

CI/CD

View Russian version of this file here

Contents

  1. Description
  2. Installation
  3. Running Tests
  4. Project Structure
  5. Documentation
  6. Coverage
  7. Allure Report
  8. Telegram Notification
  9. License

Description

This project is a set of automated UI tests written in Python using Playwright, Allure, and PyTest.

Installation

  1. Install Python: https://www.python.org/downloads/
  2. Clone the repository: git clone https://github.com/ZhikharevAl/db_web_test_automation.git
  3. Activate the virtual environment: /.venv/Scripts/activate
  4. Install dependencies: pip install -r requirements.txt

Running Tests

  1. Run tests:
    • pytest
    • pytest --numprocesses auto

The pytest --numprocesses auto command is used to run tests in parallel using the pytest-xdist plugin. To install the pytest-xdist plugin, execute the following command:

pip install -U pytest-xdist

Or:

pip install pytest-xdist

If you want to use psutil to determine the number of available processors, install the additional psutil package:

pip install pytest-xdist[psutil]

Example:

pytest --numprocesses auto --count=100 .\tests\name_test.py

The --numprocesses auto option automatically determines the number of processes equal to the number of available processors and randomly distributes tests among them. The --count=100 option specifies that each test should be run 100 times. The path .\tests\name_test.py points to the test file to be run.

numprocess.mp4
  1. Run with a specified base URL:
    • pytest --base-url https://demoblaze.com/

The pytest-base-url plugin is a simple plugin for pytest that provides an optional base URL via the command line or configuration file. You can install pytest-base-url with pip:

pip install pytest-base-url

After installation, you can specify the base URL on the command line:

pytest --base-url https://demoblaze.com/

Or you can specify the base URL in the configuration file:

[pytest]
base_url = https://demoblaze.com/
  1. Automatic test restart on failure:

If you want the test to automatically restart on failure, you can use the pytest-rerunfailures plugin. This plugin allows you to automatically rerun failed tests. To install the plugin, execute the following command:

pip install pytest-rerunfailures

Then, in the pytest.ini file, specify the following:

[pytest]
addopts = --reruns=5

286441348-049dfb7e-668a-4c6b-ba03-6794fddc7c82

  1. Generate Allure report: allure serve allure-results

Project Structure

  • .github/workflows/ - directory with workflow files
  • data/ - directory with data
  • docs/ - directory with documentation
  • tests/ - directory with tests
  • pages/ - directory with page descriptions
  • .gitignore - file with ignored files
  • .dockerignore - file with ignored files
  • conftest.py - configuration file
  • docker-compose.yml - docker-compose configuration file
  • Dockerfile - Dockerfile
  • pytest.ini - Pytest configuration file
  • requirements.txt - project dependencies file

Documentation

Descriptions of tests and documentation can be found here.

Pairwise Testing

293063023-eef58ea5-62fb-47e5-8222-93c750683260

State Transition Diagram

293064089-015b7990-d614-4986-8e5c-062fc6b6c47d

Coverage

Screenshot 2024-05-09 193751

Allure Report

Screenshot 2024-06-17 195516 Screenshot 2024-05-15 203604 Screenshot 2024-05-15 203957

Telegram Notification

For Telegram notifications, you can use a Telegram bot. 302050143-f9c81f88-df69-4824-b9f6-9ff7e5c63b66

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

This repository contains a test automation project using PyTest and Playwright. We use the ‘test cases as code’ approach and store test reports in a database. We also generate reports in Allure.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published