簡體   English   中英

引發 TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException:消息:斷言失敗

[英]raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Assertion failed

我有 Selenium Webdriver 的問題,試圖定位元素,程序給出錯誤“raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Assertion failed”

我的代碼是一個頁面對象模型:我的代碼:第一部分 -

  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"]'))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM