【问题标题】:Testcafe - dealing with videoTestcafe - 处理视频
【发布时间】:2021-02-19 01:27:04
【问题描述】:

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

当我尝试将其翻译到 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】:

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

    testcafe "chrome --autoplay-policy=no-user-gesture-required" test.js
    

    另请参阅:Start a Browser With Arguments

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-29
      • 2014-08-31
      • 2011-11-21
      • 1970-01-01
      • 2019-12-20
      • 2012-12-31
      • 1970-01-01
      相关资源
      最近更新 更多