About Debugging While Testing with Playwright

By default, Playwright waits maximum 30 seconds for each element to be accessible. If you want to intercept the code for debugging with pdb or PyCharm debugger, you likely need more time to inspect the values and step through the code execution. You can make the timeouts infinite with context.set_default_timeout(0) as follows:

1
2
3
4
5
6
7
8
9
from playwright.sync_api import sync_playwright

playwright = sync_playwright().start()
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
context.set_default_timeout(0)
page = context.new_page()
page.set_viewport_size({"width": 1200, "height": 800})
...

Testing Debugging Django 5.x Django 4.2 Django 3.2 Python 3 PyCharm Playwright pdb