Kao*_*aol 7 python exception playwright-python
我想用它Except TimeoutError来处理超时问题。但脚本总是抛出一个超时错误,而不是按照我的计划打印消息。
这是我的代码:
try:
await page.wait_for_selector("#winiframe_main", timeout=10000, state='detached')
print("The frame is detached.")
except TimeoutError:
print("The frame is not detached")
Run Code Online (Sandbox Code Playgroud)
我的代码有什么问题吗?
您必须导入TimeoutErrorfromplaywright才能捕获此异常:
from playwright.async_api import async_playwright, TimeoutError
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4692 次 |
| 最近记录: |