【问题标题】:Cypress click on html5 video buttons (play/pause, mute, scroll video, fullscreen)赛普拉斯点击 html5 视频按钮(播放/暂停、静音、滚动视频、全屏)
【发布时间】:2021-07-24 14:57:21
【问题描述】:

我正在尝试单击 html5 视频元素上的播放/暂停、静音、全屏等选项。但问题是这些在 DOM 中不可用,我无法选择元素。我尝试使用坐标单击,但它不起作用。柏树也不支持键盘操作,否则我可以使用 Tab 和空格键来执行操作。有人可以建议一个解决方案来对 html5 视频元素执行操作吗?

html5 视频示例

https://www.w3schools.com/html/html5_video.asp

【问题讨论】:

    标签: cypress cypress-cucumber-preprocessor


    【解决方案1】:

    对于静音和播放,你可以使用这个:

    it('html5 video', () => {
        cy.visit("https://www.w3schools.com/html/html5_video.asp");
        cy.get('#accept-choices').click();
        cy.get('#video1').then((video) => {
          const element = video.get(0);
          element.muted = true;
          element.play();
          return video;
        })
      });

    return video 是可选的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-28
      • 2014-03-05
      • 2012-05-06
      相关资源
      最近更新 更多