javascript - 无法使用 Test Cafe 播放视频,Click 事件什么也不做
问题描述
无法使用 Test Cafe 播放视频,点击事件未播放视频。我可以将鼠标悬停到特定元素,但是当我单击它时应该开始播放视频。但它无法播放。
const logger = RequestLogger({ url: 'URL', method: 'post' },
{ logResponseBody: true, logRequestBody: true, stringifyResponseBody: true, stringifyRequestBody: true });
const obj = 'URL';
await t.navigateTo(obj.uri);
const loader = Selector('.web_player_loader.loader');
await t.expect(loader.exists).notOk({ timeout: 30000 });
console.log('Video Started....');
const playerBase=Selector('.player-base');
await t.hover(playerBase);
await t.click(playerBase);
console.log('Logger Request Length is ',logger.requests.length);```
I am running the script using following params.
testcafe chrome --autoplay-policy=no-user-gesture-required ./tests -s takeOnFails=true --skip-js-errors=true
Getting this error in the Console.
main.dad0fa6441f0af49d386.js:2 Uncaught (in promise) TypeError: Cannot read property 'topLPVs' of undefined
at t.value (main.dad0fa6441f0af49d386.js:2)
at e.value (main.dad0fa6441f0af49d386.js:2)
at e.value (main.dad0fa6441f0af49d386.js:2)
at t.<anonymous> (main.dad0fa6441f0af49d386.js:2)
at l (vendor~main.58.ac1d1027b98ee8b3b2d1.js:9)
at Generator._invoke (vendor~main.58.ac1d1027b98ee8b3b2d1.js:9)
at Generator.next (vendor~main.58.ac1d1027b98ee8b3b2d1.js:9)
at n (hammerhead.js:15)
at value (hammerhead.js:6)
at n (vendor~main.58.ac1d1027b98ee8b3b2d1.js:2)
at a (vendor~main.58.ac1d1027b98ee8b3b2d1.js:2)
解决方案
根据您提供的调用堆栈,您的应用程序中似乎发生了错误。发生此行为的原因是 testcafe 单击速度快于最终用户,并且测试页面上的初始化代码可能没有足够的时间来完成。如果您在悬停和单击操作之间添加延迟,您能否澄清一下是否会发生相同的错误?
t.hover(playerBase)
.wait(1000)
.click(playerBase);
如果重现错误,您能否分享一个显示该错误的示例?我会在本地研究它。
推荐阅读
- javascript - Wallpaper Engine,关于自定义 Audio Visualizer 渲染的见解
- python - 如何将偶数行的数据附加到上面的奇数行?
- android - android 项目在 Linux 上构建,但不在 Windows 上
- spring-boot - 我们可以在tomcat服务器中部署spring-boot jar吗?
- php - 使用 array_splice 以外的其他方法组合两个数组
- python - Google OAuth 不会在 authlib.starlette_client 中返回 refresh_token
- swift - 错误的文件名快速保存在文档目录中
- javascript - 使用 css 属性将文本换行在两行之后
- java - 关闭舞台后,儿童舞台听众不会被杀死
- java - 如何在 ODL 控制器中配置拒绝服务过滤器