Installing Playwright in Python

Introduction

The Playwright API supports working with Python

Installation

python -m pip install --upgrade pip
python -m pip install playwright
playwright install

With playwright you don't have to bother with downloading webdrivers and adding them to PATH as it was in selenium

Let's look at each step separately (skip)

python -m pip install --upgrade pip

Requirement already satisfied: pip in /home/andrei/test/robotframework/venv/lib/python3.9/site-packages (21.3.1)

python -m pip install playwright

Collecting playwright Downloading playwright-1.17.2-py3-none-manylinux1_x86_64.whl (33.3 MB) |████████████████████████████████| 33.3 MB 6.4 MB/s Collecting greenlet>=1.0.0 Downloading greenlet-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (153 kB) |████████████████████████████████| 153 kB 3.3 MB/s Collecting websockets>=8.1 Downloading websockets-10.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (110 kB) |████████████████████████████████| 110 kB 2.8 MB/s Collecting pyee>=8.0.1 Downloading pyee-8.2.2-py2.py3-none-any.whl (12 kB) Installing collected packages: websockets, pyee, greenlet, playwright Successfully installed greenlet-1.1.2 playwright-1.17.2 pyee-8.2.2 websockets-10.1

playwright install

Downloading Playwright build of chromium v939194 - 128.9 Mb [====================] 100% 0.0s Playwright build of chromium v939194 downloaded to /home/andrei/.cache/ms-playwright/chromium-939194 Downloading Playwright build of ffmpeg v1006 - 2.6 Mb [====================] 100% 0.0s Playwright build of ffmpeg v1006 downloaded to /home/andrei/.cache/ms-playwright/ffmpeg-1006 Downloading Playwright build of firefox v1304 - 72.7 Mb [====================] 100% 0.0s Playwright build of firefox v1304 downloaded to /home/andrei/.cache/ms-playwright/firefox-1304 Downloading Playwright build of webkit v1578 - 76.7 Mb [====================] 100% 0.0s Playwright build of webkit v1578 downloaded to /home/andrei/.cache/ms-playwright/webkit-1578

Article author: Andrei Olegovich