Skip to content

🎭 Playwright for Python PyPIJoin 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.

LinuxmacOSWindows
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

fromplaywright.sync_apiimportsync_playwrightwithsync_playwright() asp:
forbrowser_typein [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()
importasynciofromplaywright.async_apiimportasync_playwrightasyncdefmain():
asyncwithasync_playwright() asp:
forbrowser_typein [p.chromium, p.firefox, p.webkit]:
browser=awaitbrowser_type.launch()
page=awaitbrowser.new_page()
awaitpage.goto('http://playwright.dev')
awaitpage.screenshot(path=f'example-{browser_type.name}.png')
awaitbrowser.close()
asyncio.run(main())

Other languages

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

About

Python version of the Playwright testing and automation library.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

14.9k stars

Watchers

155 watching

Forks

Releases

Used by

Contributors

Languages