Whenever I am using explicit wait, at times data is not getting saved in the variable:

validation_message = WebDriverWait(context.driver, 30).until(
       EC.element_to_be_clickable((By.XPATH, '//body/div[1]/div[1]/span[1]'))).text

assert (validation_message == 'Password must have at least 7 characters, 1 number, 1 uppercase letter, 1 lowercase letter and one special character.')
  • 3
    Is there a reason you're waiting for it to be clickable instead of visible? If it's just text, it's not an interactive element and it could have elements that overlay it, preventing it from being clickable, but allowing it to be visible.
    – Roger Cook
    Commented Dec 5, 2022 at 16:59

1 Answer 1


There could be many reasons why the driver is failing to find the validation_message element. You might need to decompose the problem a bit more and clarify the question to help provide some more context. What are you expecting to happen? What are we actually waiting for here in the test? e.g. is it a long running network request or an element render?

Implicit time based waits can be helpful for debugging failing tests. However the use of waits with arbitrary time values is generally regarded as an anti-pattern in UI test automation. The Selenium documentation explains that a combination of both implicit and explicit waits is also not recommended as it may result in inconsistent wait behaviour.

  • Actually trying to read text inside a validation message, Once user puts some invalid data then a validation message is thrown from backend and gets displayed on frontend in form of a toast Commented Dec 5, 2022 at 16:54
  • @HassanBari I'm assuming that there is a network request of some kind involved to a backend service as part of this validation. It might be worth investigating this request in more detail to determine if it's delaying or preventing the display of the UI element. E.g. Is the request failing? Does WebDriver timeout before a response is returned from the backend service? Commented Dec 7, 2022 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.