Full disclosure, I'm fairly new to Python and Selenium Webdriver.
I am expanding a small automation project that I've been working on. I have an in-browser chat window that, when a message is received, a file titled 'chime.mp3' will play to notify the user of a new message.
To verify the success that this audio file has played, I will need to verify that the file was called or requested via HTTP request, i.e. https://usr/bin/webapps/chime.mp3
Is there a module I could import in python, or a webdriver technique to listen for this file being requested?
Or is there a known way to verify audio files play on a certain event?
Any help is much appreciated.
To the best of my knowledge, there is no built-in functionality in Selenium (or Python) that you could use for that.
While you can't easily verify that the sound as actually been played however, you can easily verify whether your site has instructed the browser to play the file. Most likely, your site will use the HTML5 audio tag to actually play the file, and you can check for that:
WebElement audio = driver.findElement(By.tagName("audio")); // make sure any audio tag is there
// ... or ...
WebElement audio = driver.findElement(By.xpath("//audio/source[contains(@src, 'chime.mp3')]/..")); // make sure an audio tag is there that refers to chime.mp3
assertTrue(Boolean.parseBoolean(audio.getAttribute("ended"))); // make sure the audio tag has played at least once
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With