My current challenge in JavaScript involves waiting for a specific string or boolean value to be matched.
Here is the relevant JavaScript code snippet:
document.getElementById('video_html5').seeking;
When this code is executed, it returns either "false" or "true". I need to wait until the value is "false", indicating that the video is not seeking. However, I have only been able to figure out how to wait for a general JavaScript command value without being able to test for specific text matches.
new WebDriverWait(driver, 30)
.until(ExpectedConditions.jsReturnsValue("return document.getElementById('video_html5').seeking;"));
There are cases where the returned value is a string rather than a boolean, so I must also account for comparing strings.
I managed to achieve this functionality in Ruby, but I am still looking for a way to do it in Java:
wait_element = @wait.until { @driver.execute_script("return document.getElementById('vid1_html5_api_Shaka_api').seeking;").eql? false }