cypress - Cypress:如何在悬停时定位元素?
问题描述
我有一个“反应”应用程序,#controlsBar
当 mouseover 时应该可见#video-container
,但以下代码失败
cy.get("#controlsBar").should("be.hidden");
cy.get("#video-container")
.trigger("mouseover")
.then((elem) => {
cy.get(elem).children().eq(3).should("be.visible"); //this is #controlsBar
//cy.get("#controlsBar").should("be.visible"); //this failed also
cy.get("#controlsBar").invoke("show");
});
解决方案
我建议您使用cypress-real-events包。
要安装使用
npm install cypress-real-events
.然后在
cypress/support/index.js
文件下写入import "cypress-real-events/support";
。然后在你的测试中你可以写:
cy.get("#video-container").realHover()
推荐阅读
- rasa-nlu - 最新的 Rasa 核心模型未检测到任何实体
- c++ - 我的 SDL2 程序需要哪些二进制文件才能在另一台未安装 SDL2 的计算机上运行
- android - Android Kotlin Pusher Chatkit - 错误 - 需要房间会员资格
- python-3.x - 排序和使行具有相同的索引pandas python
- php - 通过 PDO 在 docker 容器上连接到 Mysql 时出现问题,但命令行有效
- jquery - Laravel 数据表错误 - 无法重新初始化数据表
- node.js - 如何使用 Node.js 读取 Django 应用程序中的服务器文件?
- html - Angular 5 - 如何从 *ngIf div 中的元素获取ElementById?
- android - 检测用户是否进入或退出 Flutter 中的选项卡
- google-app-engine - Google Datastore - 确保只为具有特定祖先键的实体创建一个实体