Testcafe - 处理视频

问题描述 投票:4回答:1

我正在测试一个带有嵌入式视频的页面,其中使用我可以播放,停止并获得当前播放时间的控制台。

当我尝试将其翻译为Testcafe时,我会收到错误。这是我在控制台上工作的内容:

var vid = document.querySelector('.video-tech')
if (vid.paused === false) {
  vid.pause();
} else {
  vid.play();
}
document.querySelector('.video-current-time-display').innerText // 0:33

然后我尝试使用Testcafe语法获取这些元素:

const playVideo = ClientFunction(() => {
      document.querySelector('.video-tech').play();
    });

const pauseVideo = ClientFunction(() => {
      document.querySelector('.video-tech').pause();
    });

到现在为止还挺好。问题是我不能使用If-Else语句和ClientFunction

我的目标是从current-time-display获取文本并让视频播放几秒钟,然后停止。

javascript video jquery-selectors testcafe current-time
1个回答
3
投票

它看起来像浏览器政策限制,您可能需要指定(在Chrome浏览器的情况下)--autoplay-policy=no-user-gesture-required标志(chrome:// flags /#autoplay-policy):

testcafe "chrome --autoplay-policy=no-user-gesture-required" test.js
© www.soinside.com 2019 - 2024. All rights reserved.