Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Python won't let me use the == operator in the until() function. I'm pretty sure it doesn't accept booleans. The first answer still returns the same error message selenium.common.exceptions.StaleElementReferenceException: Message: {"errorMessage":"Element is no longer attached to the DOM" Commented Aug 28, 2017 at 12:28
  • it's not a Boolean, it's a function. I have tested it and it works just fine. Commented Aug 28, 2017 at 12:42
  • This does work! Thanks! may I ask if instead of comparing the string? to and "expected text"? How can we do this we regular expressions? hmm... also may I clarify that what happens here to the second code answer is that the driver waits for an element base on the XPATH given if the innerHTML of it is equal to the expected text right? THANKS! Commented Mar 13, 2021 at 15:59
  • I tried this WebDriverWait(browser, 20).until(lambda browser: re.search(regex,browser.find_element_by_xpath(my_xpath).get_attribute("innerHTML"))) and it works thanks! Commented Mar 13, 2021 at 16:08