Skip to content

Latest commit

 

History

History
102 lines (69 loc) · 3.64 KB

README.md

File metadata and controls

102 lines (69 loc) · 3.64 KB

Pytest Playwright UI Tests

This is a suite of automated end-to-end UI tests for the AODN Portal v2. The tests are implemented using pytest framework and Playwright for interactions with the web browser.

Execute Tests Using Docker

  1. Prerequisites: Docker installed on your system.

  2. Run playwright tests against the current local version of the aodn-portal-v2:

    yarn playwright

Setup Guide for Local Development of the Test Suite:

Python version:

Python 3.10.x is required. UNIX/MacOS users can use Pyenv for Python version management.

However, This guide provides instructions for setting up your working environment using Conda to create a virtual environment with the required Python version that should work on both UNIX/MacOS and Windows. Additionally, we'll utilize Poetry to manage packages within the conda environment.

Installation:

If you don't have Conda and Poetry installed, you'll need to install them before setting up the project.

Poetry should be installed globally on your system, not within a Python virtual environment. We will utilize pipx to ensure that Poetry remains isolated in the global scope while also being accessible from anywhere on your system.

Conda

To install Conda, please refer to the official guide.

Poetry

  1. First, install pipx by following the instructions in the official repository. Ensure that pipx is added to your system's PATH variable after installation.

  2. For OSX and Z Shell users, open up ~/.zshrc and add this:

    export PATH="$HOME/.local/bin:$PATH"
  3. Then, proceed to install Poetry by running the following command:

    pipx install poetry

Project Setup:

  1. Open your terminal (Linux, MacOS) or the Miniconda/Anaconda Prompt (Windows).

  2. Navigate to the /playwright directory.

  3. Create a conda environment using the environment.yml file:

    conda env create -f environment.yml

    This command creates a virtual environment with the name aodn-portal-v2 and installs the required python version.

  4. Activate this conda environment:

    conda activate aodn-portal-v2
  5. Install dependencies defined in pyproject.toml:

    poetry install
  6. Install all supported browsers with system dependencies:

    playwright install --with-deps
  7. Configure project related settings:

    a) Open the settings.toml file

    b) Update the required values according to your environment.

Running Tests:

  1. Run all tests:

    pytest
  2. Run tests with visible browsers

    pytest --headed
  3. To run tests in parallel, use the --numprocesses flag:

    pytest --numprocesses auto

    More configurable options can be found in the official documentation.

Test Report:

Test reports are generated using pytest-html. The generated report for the latest test run will be stored inside the /playwright/reports directory. The link to view the traces: https://trace.playwright.dev/

Debug on VSCode

Install https://playwright.dev/docs/getting-started-vscode Playwright Test for VSCode