【发布时间】:2023-01-11 00:55:52
【问题描述】:
我遇到了 selenium + chrome-driver 的问题。
我正在使用的 URL:https://tixcraft.com/ticket/verify/23_ttp6th/12494 我想做的是在我故意发送错误密钥时接受错误警报。但是,代码总是卡住,除非我手动接受它。
veri_box = self.std_wait.until(
EC.element_to_be_clickable((By.ID, 'checkCode'))
)
veri_box.send_keys("randomKey")
veri_box.send_keys(Keys.ENTER)
#the code gets stuck here unless I manually click OK on the alert.
self.std_wait.until(EC.alert_is_present()).accept()
知道可能是什么问题吗? 谢谢?
我试过在输入框中手动键入随机值并按 Enter 键。代码以这种方式成功检测到警报。
我希望使用 Selenium 键入值是相同的,但由于某种原因它不起作用。
【问题讨论】:
-
顺便说一句,self.std_wait = WebDriverWait(self.driver, 1)