Youโ€™re the Expert!

pynfinity

playwright

Playwright

Your complete recipe for mastering Playwright โ€” course modules & quick-reference guide in one place.

AU Recipe Module 3 sections

BASICS

Launch a Browser and Navigate to a Page

Explore the concepts and examples below to master this topic.

Code Example
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://pynfinity.com")
    print(page.title())
    browser.close()
Video Walkthrough
Coming soon โ€” in-depth video explanation for this topic.

Click a Button and Enter Text

Explore the concepts and examples below to master this topic.

Code Example
page.fill("#username", "santosh")
page.click("#submit")
Video Walkthrough
Coming soon โ€” in-depth video explanation for this topic.

INTERMEDIATE

Take a Screenshot of a Web Page

Explore the concepts and examples below to master this topic.

Code Example
page.screenshot(path="screenshot.png")
Video Walkthrough
Coming soon โ€” in-depth video explanation for this topic.

Handle Alerts and Pop-ups

Explore the concepts and examples below to master this topic.

Code Example
page.on("dialog", lambda dialog: dialog.accept())
Video Walkthrough
Coming soon โ€” in-depth video explanation for this topic.

ADVANCED

Run Playwright Tests in Headless Mode

Explore the concepts and examples below to master this topic.

Code Example
browser = p.chromium.launch(headless=True)
Video Walkthrough
Coming soon โ€” in-depth video explanation for this topic.

Execute Tests in Parallel with Pytest

Explore the concepts and examples below to master this topic.

Code Example
pytest --numprocesses=2
Video Walkthrough
Coming soon โ€” in-depth video explanation for this topic.
โšก Quick Reference โ€” Recipe

Use the reference cards below for fast lookup. Perfect for brushing up on syntax while you cook your code. ๐Ÿณ

Launch a Browser and Navigate to a Page
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://pynfinity.com")
    print(page.title())
    browser.close()
Click a Button and Enter Text
page.fill("#username", "santosh")
page.click("#submit")

Take a Screenshot of a Web Page
page.screenshot(path="screenshot.png")
Handle Alerts and Pop-ups
page.on("dialog", lambda dialog: dialog.accept())

Run Playwright Tests in Headless Mode
browser = p.chromium.launch(headless=True)
Execute Tests in Parallel with Pytest
pytest --numprocesses=2

Recipe Complete! ๐ŸŽ‰

You've explored the full Playwright recipe.
Keep practising โ€” a language a day keeps AI away! ๐Ÿค–

Back to AU Courses


Pynfinity
Install Pynfinity Add to home screen for the best experience