In my web application built with Angular, I have a <video>
element that I would like to test using Protractor.
What I need to do is
1) Play and pause the video
2) Assert whether the video is playing or not
How can I accomplish this?
In my web application built with Angular, I have a <video>
element that I would like to test using Protractor.
What I need to do is
1) Play and pause the video
2) Assert whether the video is playing or not
How can I accomplish this?
Yes , its possible. There is a HTML element paused
which returns a boolean and tells if the video is paused or playing.
Below is the code I am using and it works like charm.
async returnVideoState() {
let pausedState = browser.executeScript(() => {
return document.getElementsByClassName('videoelm').paused;
});
return pausedState;
}
async assertIfVideoIsPlaying(bool) {
_isPaused = await this.returnVideoState();
expect(_isPaused).toBe(bool);
}
Usage:
async pauseVideo() {
await this.pauseVideo();
await this.assertIfVideoIsPlaying(true);
}
When video is Paused it should return true and false when being played.