As stated in the title, is it possible to record audio from a website under test using cypress. For example from an audio tag or a youtube video. Such that it is audible in the video recorded by cypress.
Asked
Active
Viewed 367 times
1 Answers
0
Yes, you can use this if you want to ensure audio is playing for the client....if you're using audio or video elements.
const expectPlayingAudio = () => {
cy.get('audio,video').should((els)=>{
let audible = false
els.each((i, el)=>{
console.log(el)
console.log(el.duration, el.paused, el.muted)
if (el.duration > 0 && !el.paused && !el.muted) {
audible = true
}
// expect(el.duration > 0 && !el.paused && !el.muted).to.eq(false)
})
expect(audible).to.eq(true)
})
}
describe('page', () => {
it('works', () => {
cy.visit('/')
expectPlayingAudio()
})
})

Usama Arslan
- 111
- 4
-
For more in-depth knowledge see this thread [cypress audio and video tetsing](https://github.com/cypress-io/cypress/issues/1750) here – Usama Arslan Sep 21 '22 at 11:55
-
Unfortunately this wont work, the client specifically wants a video produced by cypress with the audio in it. – Mino k Sep 21 '22 at 11:57
-
I believe this is not possible yet – Usama Arslan Sep 21 '22 at 11:59
-
@Minok do you know if this is possible yet? I have a use case for this too. I can hear my ` – Adam Jul 11 '23 at 01:02