Check If Audio Is Playing Correctly Using Selenium
I am writing tests for an HTML5 game, and I want to check that the audio is loading and starting correctly. Is there a way to check this using Selenium? or do I need to do this at
Solution 1:
You could check the audio element, after it should've started playing:
WebElementaudio= driver.findElement(By.tagName("audio"));
StringcurrentTime= audio.getAttribute("currentTime");
try {
assertTrue(Double.parseDouble(currentTime) > 0.0);
} catch(NumberFormatException ex) {
assertEquals(ex, null);
}
If it failed to load, or never started, then this test should fail.
Post a Comment for "Check If Audio Is Playing Correctly Using Selenium"