Say I have an element with value = 1. Then I click on some button, it takes a while to load and then the element value updates, say value = 2. Now, what I want to do - As soon as I clicked the button, I want to constantly check the element value, wait during the time period and as soon as the value updates (i.e. 2), the wait should stop.
Currently I use, simple Thread.sleep(milliseconds) to just explicitly wait for some time.
I was hoping to use the WebDriverWait with Expected Conditions in this scenario, but not sure how to do the constant check on the value and end the wait as soon as the value gets updated to 2.
Kindly suggest how can I achieve this?
My solution in Java: