2

我正在尝试测试当前是否正在播放 Html 视频,但似乎无法弄清楚如何获取currentTime. 我一直在尝试这样的事情:

async videoIsPlaying(indexOfVideo = 0) {
    return ClientFunction(() => {
        const video = document.getElementsByTagName('video')[indexOfVideo];
        return video.currentTime > 0;
    });
}

但我的期望:

await t.expect(await playerPage.videoIsPlaying()).eql(true);

正在返回:

AssertionError: expected [Function: __$$clientFunction$$] to deeply equal true

我究竟做错了什么?另外,我使用的.eql()是因为.ok()任何结果都返回真值。

4

1 回答 1

3

啊……只需要触发函数,并因此传入索引……

async videoIsPlaying(indexOfVideo = 0) {
    return await ClientFunction((indexOfVideo) => {
        const video = document.getElementsByTagName('video')[indexOfVideo];
        return video.currentTime > 0;
    })(indexOfVideo);
}

仅供参考,此功能位于页面对象中

于 2018-06-27T19:51:49.697 回答