问题描述
我想用 Except TimeoutError
来处理超时问题。但是脚本总是向我抛出 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")
我的代码有问题吗?
解决方法
您必须从 std::promise
导入 TimeoutError
才能捕获此异常:
playwright