Skip to content

This tutorial provides a step-by-step guide on using Python and Playwright for WebUI test automation

License

Notifications You must be signed in to change notification settings

ruzeynalov/playwright-python-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python WebUI Test Automation with Playwright Tutorial

This tutorial provides a step-by-step guide on using Python and Playwright for WebUI test automation.

Table of Contents

Introduction

In this tutorial, we will explore how to use Python and Playwright to automate WebUI tests.

Prerequisites

Before getting started, make sure you have the following prerequisites installed:

   python3 -m ensurepip
  • venv
   pip install virtualenv

Getting Started

To get started with Python and Playwright, follow these steps:

  1. Clone or download this repository.
  2. Open a terminal and navigate to the project directory.
  3. Create and activate isolated environment by running following commands
python3 -m venv venv

For Linux & Mac run

source venv/bin/activate

For Windows run

venv\Scripts\activate.bat
  1. Install the project dependencies by running the following command:
pip3 install -r requirements.txt

Running UI Tests

  1. Running UI tests in headless mode Chrome
python3 -m pytest -m webtest tests --verbose
  1. Running UI tests in headed mode & specific browser(chromium,firefox,webkit)
python3 -m pytest -m webtest tests --browser webkit  --headed --verbose
  1. Running UI tests in headed mode in all browsers in parallel
python3 -m pytest -m webtest tests --numprocesses auto --browser chromium --browser firefox --browser webkit  --headed --verbose

Running API Tests

Running API tests using Playwright

python3 -m pytest -m apitest -s tests --screenshot on --verbose

Running All Tests

  1. Running All tests using Playwright in headless mode
python3 -m pytest -s tests --screenshot on --verbose
  1. Running All tests using Playwright in headed mode
python3 -m pytest -s tests --screenshot on --verbose --headed

Debugging Tests

In order to launch Playwright inspector and debug specific tests run following commands

PWDEBUG=1 python3 -m pytest -s -k test_basic_duckduckgo_search --verbose

Allure Report

By default test summary will be posted into commandline

In order to generate HTML report using Allure reporting framework run tests with --alluredir parameter

python3 -m pytest -s --alluredir=allure-results tests --numprocesses auto --browser chromium --browser firefox --browser webkit --screenshot on --video on --headed --verbose

And the generate and open report in browser by running

allure serve -h localhost

License

This project is licensed under the MIT License.

About

This tutorial provides a step-by-step guide on using Python and Playwright for WebUI test automation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages