0

I have done a lot of searching but can't seem to make Selenium wait for an id to NOT have a certain value. Some things I have tried:

This times out:

wait.until(EC.text_to_be_present_in_element_value((By.ID, "price"), not " $0.00"))

This throws TypeError: 'bool' object is not callable:

wait.until(not EC.text_to_be_present_in_element_value((By.ID, "price"), " $0.00")) 

This throws TypeError: coercing to Unicode: need string or buffer, bool found:

wait.until(EC.text_to_be_present_in_element((By.ID, "price"), not " $0.00")) 

Note:

  • This it the only value in the price ID

  • wait = WebDriverWait(browser, 10)

Bonus Answer:

The entire issue is that the price starts at " $0.00" then changes to multiple elements which displays a loading gif. Finally, it would display the actual price. To finish my task I used the accepted answer below (until_not) to check that the 0 has become the gif, and an until with a custom function to check the regex not to match "$0". I used the function from here with the regex pattern of "\$(?!0)\w".

Community
  • 1
  • 1

1 Answers1

1

wait has another method until_not which inverts the expectation

EDIT: Try:

wait.until_not(EC.text_to_be_present_in_element_value((By.ID, "price"), " $0.00"))
Lucas Tierney
  • 2,503
  • 15
  • 13
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/14992809) – cb0 Jan 25 '17 at 11:44
  • It does, but I've provided clarification on how to use it, which the author already knows – Lucas Tierney Jan 25 '17 at 13:54
  • Thank you for this answer and I apologize for my late response. I understood the answer before the edit, however soon after I realized I needed a bit more work. I put some more details into my question to hopefully help others. – Patrick Artounian Jan 26 '17 at 20:21