I have successfully used wait_for_non_empty_text() from this discussion: How to wait for presence of an element with non empty content? in my Selenium v3 project, but after upgrade to Selenium 4, there is no longer _find_element() function in expected_conditions module, so wait_for_non_empty_text() no longer works.
Looks like Python\Python311\Lib\site-packages\selenium\webdriver\support\expected_conditions.py was completely re-written for Selenium 4.
Is there a way to change this custom expected condition to still be able to call this function using "wait.until()" under Selenium 4?
class wait_for_non_empty_text(object):
def __init__(self, locator):
self.locator = locator
def __call__(self, driver):
try:
element_text = EC._find_element(driver, self.locator).text.strip()
return element_text != ""
except StaleElementReferenceException:
return False
I tried for hours but cannot figure out how to make it work without _find_element().
Thanks!