playwright-python README

The project's README from github.com/microsoft/playwright-python. As one markdown file: README.md.

🎭 Playwright for Python PyPI Join Discord

Playwright is a Python library to automate Chromium, Firefox and WebKit browsers with a single API. Playwright delivers automation that is ever-green, capable, reliable and fast. See how Playwright is better.

Linux macOS Windows
Chromium 151.0.7922.34 ✅ ✅ ✅
WebKit 26.5 ✅ ✅ ✅
Firefox 153.0 ✅ ✅ ✅

Documentation

https://playwright.dev/python/docs/intro

API Reference

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

Example

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    for browser_type in [p.chromium, p.firefox, p.webkit]:
        browser = browser_type.launch()
        page = browser.new_page()
        page.goto('http://playwright.dev')
        page.screenshot(path=f'example-{browser_type.name}.png')
        browser.close()
import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        for browser_type in [p.chromium, p.firefox, p.webkit]:
            browser = await browser_type.launch()
            page = await browser.new_page()
            await page.goto('http://playwright.dev')
            await page.screenshot(path=f'example-{browser_type.name}.png')
            await browser.close()

asyncio.run(main())

Other languages

More comfortable in another programming language? Playwright is also available in

playwright-python (microsoft/playwright-python)

Searching Database…

What is this?Playwright for Python is the official Python library for automating Chromium, Firefox and WebKit browsers through a single API, built for testing and browser automation.
Is it a library I code against, or a standalone app?A library: you install it into a Python project and write Python scripts or tests that call its API to drive the browsers — there is no GUI of its own.
How do I get it into my project?Install the package with pip install playwright, then use the Documentation, API Reference and Example the README links to write your first automation script.
Which browsers does it drive — and do I have to set them up myself?It targets pinned Playwright builds of three engines: Chromium 151.0.7922.34, Firefox 153.0 and WebKit 26.5, so you work against known browser versions instead of whatever is installed locally.
Is it only for test suites, or general browser automation too?General automation counts too: the repo describes it as a testing and automation library, and the README pitches automation that is 'ever-green, capable, reliable and fast'.
Will it run on my Linux box, my Mac and my Windows PC?Yes — the README's compatibility table ticks all three engines as working on Linux, macOS and Windows.
Is this the same Playwright that JavaScript developers use?Yes — it is the official Python version of Playwright, which also ships for Node.js (JavaScript/TypeScript), .NET and Java.
Is it free to use, even for commercial work?Yes — microsoft/playwright-python is open source under the Apache-2.0 license, so there is no cost for personal or commercial automation.
Creator
microsoft
Size
10.1 MB
Stars
15K
Age
6y
Commits · 90 Days