1
votes

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.

1
Post the relevant html and the locator you are using. - Guy
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
The selector looks ok, I'm guessing it's inside <iframe> tag? - Guy
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
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

1 Answers

0
votes

In the first time you open the site the email field doesn't have class input-error. Try

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