https://playwright.dev/python/docs/inspector
設置PWDEBUG環境變量以在調試模式下運行腳本。這會配置 Playwright 以進行調試並打開檢查器。
打開方式:
1、bash模式:PWDEBUG=1 pytest -s
2、powershell模式:
$env:PWDEBUG=1
pytest -s
3、batch模式:
set PWDEBUG=1
pytest -s
windows pycharm這樣可打開debug模式

打開后可以點擊開始執行

可以在debug模式下調整元素定位

