1

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.

Hermine
  • 11
  • 1
  • Post the relevant html and the locator you are using. – Guy Feb 19 '20 at 06:32
  • 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: – Hermine Feb 19 '20 at 06:40
  • The selector looks ok, I'm guessing it's inside ` – Guy Feb 19 '20 at 06:44
  • let me copy the whole html code: – Hermine Feb 19 '20 at 06: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 '20 at 07:00
  • No, unfortunately, it raises the same error. – Hermine Feb 19 '20 at 07:26
  • @Guy it still has the same error, I checked it one more time. – Hermine Feb 19 '20 at 13:45
  • Than it's in ` – Guy Feb 19 '20 at 13:47
  • Thanks for the reply. I try to click on the email field here https://www.shein.com/user/auth/login?direction=nav – Hermine Feb 19 '20 at 14:01

1 Answers1

0

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"]'))
Guy
  • 46,488
  • 10
  • 44
  • 88