Showing posts with label xpath. Show all posts
Showing posts with label xpath. Show all posts

Wednesday, November 21, 2018

Python - How to wait for presence of an element with non empty text?

Hello!

Sometimes it's useful to wait for an element with non empty text. The question is how to do it with Selenium in Python? Pretty easy! You can find an answer below.

If xpath is absolute, then you can wait for your element with non empty text like this:
# xpath - xpath of your element

WebDriverWait(driver, 30).until(lambda driver: driver.find_element_by_xpath(xpath).text.strip() != '')