gpt4 book ai didi

python - 引发TimeoutException(消息,屏幕,堆栈跟踪)selenium.common.exceptions.TimeoutException : Message: Assertion failed

转载 作者:太空宇宙 更新时间:2023-11-03 19:43:26 27 4
gpt4 key购买 nike

我在使用 Selenium Webdriver 时遇到问题,尝试定位该元素时,程序给出错误“raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Assertion failed”

我的代码使用页面对象模型:我的代码:第 1 部分 -

  def located_element(self, locator):
wait = WebDriverWait(self.driver, 30)
element = wait.until(EC.presence_of_element_located(locator))
return element

第二部分

 def enter_email(self, user):
email_field = self.located_element(self.locator.Email)
email_field.click()
email_field.send_keys(Users.get_user(user)["email"])

第三(运行)

我尝试了相关问题的一些建议,但对我没有帮助。起初,它找不到该元素,这就是我添加 EC 的原因,但现在它会引发错误。请帮助我,我该如何处理异常。我也尝试过使用 xpath 和 css-selector 来定位。

最佳答案

第一次打开网站时,电子邮件字段没有类input-error。尝试一下

email_field = self.located_element((By.CSS_SELECTOR, '[data-login-source="loginPage"] [name="email"]'))

关于python - 引发TimeoutException(消息,屏幕,堆栈跟踪)selenium.common.exceptions.TimeoutException : Message: Assertion failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60294302/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com