相关文章推荐
沉着的抽屉  ·  python for循环 ...·  1 周前    · 
一直单身的手链  ·  panda ...·  5 天前    · 
想出国的拐杖  ·  python dataframe ...·  昨天    · 
玩足球的乒乓球  ·  Ruby On ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

I have a problem with Selenium Webdriver, trying to locate the element, the program gives an error "raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Assertion failed"

My code is with a page-object model: My code: 1st part -

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

2nd part

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

3rd(running)

I have tried some recommendations from related issues but it didn't help me. At first, it couldn't find the element, that's why I added EC, but now it raises an error. Please, help me, how can I handle the Exception. I have tried the locator both with xpath and css-selector too.

Thank you for your answer. The css selector I used - Email = (By.CSS_SELECTOR, "input.input-error") and Xpath = "//input [@class = 'input-error']" and html: <input placeholder="" autocomplete="" type="email" name="email" class="input-error"> – Hermine Feb 19, 2020 at 6:40 let me copy the whole html code: <script> gbCommonInfo.pageType = 'login' </script> <div class="outermost-vue-loading vue-loading-login j-vue-loading-login"></div> <div class="c-login container-fluid-1200 j-login-container she-v-cloak-none" v-cloak> <div class="row"> <div class="c-forgotpsd col-xs-10 col-xs-offset-1" v-show='forgetPassword.showForm'> <h2>Forgotten Password</h2> There aren'n any tags here. – Hermine Feb 19, 2020 at 6:54 Does wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "input.input-error"))) work? try it directly, without passing it as a parameter. – Guy Feb 19, 2020 at 7:00

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.