Playwright是由微软公司2020年初发布的新一代自动化测试工具,相较于目前最常用的Selenium,它仅用一个API即可自动执行主流浏览器(Chromium、Firefox、WebKit)自动化操作。
安装
(venv) lifeng@apple bin % pip3 install playwright
Collecting playwright
Downloading playwright-1.17.0-py3-none-macosx_10_13_x86_64.whl (29.6 MB)
|████████████████████████████████| 29.6 MB 26 kB/s
Collecting pyee>=8.0.1
Downloading pyee-8.2.2-py2.py3-none-any.whl (12 kB)
Collecting websockets>=8.1
Downloading websockets-10.1-cp39-cp39-macosx_10_9_x86_64.whl (96 kB)
|████████████████████████████████| 96 kB 257 kB/s
Requirement already satisfied: greenlet>=1.0.0 in /Users/lifeng/python-virtualenv/venv/lib/python3.9/site-packages (from playwright) (1.1.2)
Installing collected packages: websockets, pyee, playwright
Successfully installed playwright-1.17.0 pyee-8.2.2 websockets-10.1
安装好playwright
库以后,再安装相应的浏览器:
(venv) lifeng@apple bin % playwright install chromium
Downloading Playwright build of chromium v939194 - 119.9 Mb [=======] 100% 0.0s
Playwright build of chromium v939194 downloaded to /Users/lifeng/Library/Caches/ms-playwright/chromium-939194
Downloading Playwright build of ffmpeg v1006 - 1.1 Mb [=============] 100% 0.0s
Playwright build of ffmpeg v1006 downloaded to /Users/lifeng/Library/Caches/ms-playwright/ffmpeg-1006
(venv) lifeng@apple bin % playwright install firefox
Downloading Playwright build of firefox v1304 - 71.7 Mb [=&