【发布时间】:2022-07-04 21:39:27
【问题描述】:
使用 Python 版 Playwright,我需要捕捉页面是否显示获胜者或失败者消息。
我可以等待获胜者消息显示如下:
new_selector = "text=Your are a winner"
page.wait_for_selector(new_selector)
handle = query_selector(new_selector)
# do something with handle
但是我能做些什么来等待两个不同的事情呢? (不仅是文本,任何类型的选择器)
我可以试试无限循环:
new_selector1 = "text=Your are a winner"
new_selector2 = "text=Better luck next time"
while True:
handle = query_selector(new_selector1)
if handle:
break
handle = query_selector(new_selector2)
if handle:
break
time.sleep(0.25)
# write my own timeout here
# do something with handle
但是剧作家中有什么东西可以让我等待两个句柄 并参加第一场比赛?
【问题讨论】:
-
有链接就好了,没听说过。
标签: python playwright webautomation playwright-python