When a postcode(zipcode)field is filled, I want to wait until the address and city name fields are automatically retrieved and filled before other actions are performed. For this case I'm using text_to_be_present_in_element in combination with a wait. See below code:
def _wait_for_text_is_displayed(self, locator, timeout, text):
try:
wait = WebDriverWait(self.driver, timeout)
wait.until(expected_conditions.text_to_be_present_in_element((locator["by"], locator["value"]), text))
except TimeoutException:
return False
return True
When I call the the method it behaves unexpectedly. It waits a second and continues not considering the text i'm expecting and thus not throwing an TimeoutExpection. It always passes no matter the text value.
self._wait_for_text_is_displayed(self.locater, 1, 'kjdsahfkjhasf')
Aucun commentaire:
Enregistrer un commentaire