Introduction and records of installing playwright under Python virtual environment venv

Introduction to playwright

Playwright is an open source library for automated web browser testing and web scraping. It is developed by Microsoft and supports Chrome, Firefox , Safari, Edge and WebKit browsers. A key feature of Playwright is its ability to run on all major operating systems (including Windows, Linux, and macOS), and it provides some powerful features such as cross-browser testing, support for headless browsers, parallel execution of tests, Screenshots of elements and simulated input, etc. It mainly has the following advantages:

  1. Playwright supports all current mainstream browsers, including Chrome and Edge (based on Chromium), Firefox, Safari (based on WebKit), and provides a complete API for automatic control.

  2. Playwright supports mobile page testing, using device emulation technology allows us to test responsive web applications in mobile web browsers.

  3. Fast and stable, it can run even in large and complex web applications. Compared with Selenium, the biggest advantage of Playwright is that it does not need to manually install the driver, and it has better performance and more functions. So in the field of reptiles, Playwright is a better choice .

  4. Playwright supports headless mode and non-headless mode testing of all browsers. Headless browsers are supported, so tests can be run without a visible interface, improving testing efficiency. Note: If not set to False, the default is to start the browser in headless mode, and we can't see any window .

  5. Rich APIs are provided to perform various operations, such as taking screenshots, simulating input, intercepting network requests, etc. When the page is loaded, it will automatically wait for the corresponding node to load, which greatly simplifies the complexity of API writing .

download link

offline

https://github.com/microsoft/playwright-python

online

1. Enter the venv\Scripts directory and call python in the virtual environment

2. Install playwright

pip.exe install playwright

3. Verification

playwright.exe -V

4. Install the browser plug-in

python -m playwright install

 5. Install the Pytest driver plugin

pip.exe install pytest-playwright

API manual

https://playwright.dev/python/docs/api/class-playwright

Guess you like

Origin blog.csdn.net/u012206617/article/details/132687937