Skip to content
Β 
Β 

Latest commit

Β 

History

166 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎭 Playwright Python Example 🎭

twitter dev run nightly Imports: isort Code style: black

πŸ“ƒ Articles written about this project

πŸ› οΈ Tech Stack

Tool Description
allure-pytest Allure reporting with your Pytest tests for better reporting
playwright A Python library to automate the Chromium, WebKit, and Firefox browsers through a single API.
pytest A popular testing framework for Python
pytest-base-url Pytest plugin for setting a base URL for your tests
pytest-playwright Pytest plugin for Playwright integration for browser automation testing
requests A versatile library for making HTTP requests in Python

βš™οΈ Setup Instructions

Step 1: Clone the project

git clone https://github.com/nirtal85/Playwright-Python-Example
cd playwright-python

Step 2: Create and activate a virtual environment

For Windows:

py -m pip install --user virtualenv
py -m venv env
.\env\Scripts\activate

For Mac:

python3 -m pip install --user virtualenv
python3 -m venv venv
source venv/bin/activate

Step 3: Install Poetry

pip install poetry

Step 4: Install Project Dependencies

poetry install --no-root

Step 5: Install playwright

playwright install

πŸƒβ€β™‚οΈ Running Tests

pytest

When no browser was selected then chrome will be used.

  • Run according to tags:
pytest -m <tag_name>

πŸ“Š Viewing Test Results

Install Allure Commandline To View Test results

For Windows:

Follow the instructions here to install Scoop.
Run the following command to install Allure using Scoop:

scoop install allure

For Mac:

brew install allure

View Results Locally:

allure serve allure-results

View Results Online:

View allure results via Github pages

View trace results:

  1. Navigate to the Playwright Trace Viewer
  2. Locate the trace file stored under the test-results folder. This file is generated after running your tests. Click on the 'Upload' button in the Playwright Trace Viewer and select your trace file.
  3. After uploading, the trace viewer will display a detailed timeline of events that occurred during your test. This includes network requests, JavaScript execution, and browser interactions. You can click on individual events for more details.

ℹ️ View Help And Other CLI Options

pytest --help

Pre Commit

Run Pre Commit Checks Automatically

pre-commit install

Bump Pre Commit Hooks Version

pre-commit autoupdate

Run Pre Commit Checks Manually On The Entire Project

pre-commit run --all-files

About

Playwright Python example project with pytest and Allure report

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages