I'm testing a page with an embedded video where using the console I can play, stop, and get the current playing time.
When I try to translate that to Testcafe, I get errors. Here's what I have working on the console:
var vid = document.querySelector('.video-tech')
if (vid.paused === false) {
vid.pause();
} else {
vid.play();
}
document.querySelector('.video-current-time-display').innerText // 0:33
Then I try to get these elements using the Testcafe syntax:
const playVideo = ClientFunction(() => {
document.querySelector('.video-tech').play();
});
const pauseVideo = ClientFunction(() => {
document.querySelector('.video-tech').pause();
});
So far so good. The problem is that I cannot work with an If-Else statement and the ClientFunction
.
My goal is to get the text from the current-time-display
and let the vide play for a few seconds, then stop.