I have a page which has a "status" field, which has a value "In Progress". Now on some action (button click), the status changes to Completed. I need to check for the same using Selenium.
getVisibleElement(By.id("status")).getText()
Now the issue is the status does not change immediately from In Progress to Completed, once the button is clicked. It happens after an AJAX response is received in some seconds. And when my code tries to assert the status text, it actually gets the stale value In Progress and hence it fails the test.
Again please remember even though getVisibleElement() has timeout defined, it does not help me here since the element is anyways present. It is just rendered again on AJAX request (post button click).
How do I fix the same? Can adding a fixed delay work, just before the assert. If yes, how do I do that in selenium?