【问题标题】:using webdriverio browser object how to check video is playing or not使用 webdriverio 浏览器对象如何检查视频是否正在播放
【发布时间】:2021-03-04 18:11:20
【问题描述】:

使用 webdriverio 浏览器对象我正在获取视频对象。

const videoPlayer = browser.$(selector);

我在 WebdriverIO.Element videoPlayer 中没有看到 currentTime 或正在播放的属性。如何使用 webdriverio api 测试嵌入的视频是否正在播放?

【问题讨论】:

标签: video webdriver-io


【解决方案1】:

要操作 iframe 中的元素,您应该先切换到 iframe。

describe('video', () => {
  it('manipulate video', () => {
    browser.url('https://www.volvocars.com/ph/why-volvo/human-innovation/future-of-driving/safety/a-million-more')

    // get rid of cookies
    browser.execute(`document.cookie = "OptanonAlertBoxClosed=${new Date().toISOString()};";`)
    browser.refresh()

    // open video
    const video1 = $('.videoWrapperItemList')
    expect(video1).toBeClickable()
    video1.click()

    // Important! Switch to iframe to interact with video player
    const videoIframe = $('#IframeExteriorTwoyoutube.video-active')
    browser.switchToFrame(videoIframe)

    const player = $('#movie_player')

    // video is playing
    expect(player).toHaveElementClass('playing-mode')

    // pause video
    const playPauseButton = $('.ytp-play-button')
    expect(playPauseButton).toBeClickable()
    playPauseButton.click()

    // video is paused
    expect(player).toHaveElementClass('paused-mode')

    // check current time
    expect($('.ytp-time-current')).toHaveTextContaining('0:0')

    browser.pause(2000) // demo purposes
  })
})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-18
    • 2013-08-20
    • 2021-01-31
    • 2015-06-20
    • 1970-01-01
    • 2017-03-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多