html - 如何使用柏树测试悬停时的样式更改
问题描述
我想在将鼠标悬停在表格行上时测试样式,但我无法实现:
这是我的测试代码:
it("Table rows hover styles should be correct", () => {
cy.get("table>tbody>tr").each(($el, index, $list) => {
$el.trigger("mouseover");
expect($el).to.have.css("background-color", "rgb(242, 242, 242)");
});
});
但background-color
值是悬停之前的值。
这是柏树错误:
expected '<tr>' to have CSS property 'background-color' with the value 'rgb(242, 242, 242)', but the value was 'rgba(0, 0, 0, 0)'
解决方案
您为什么不尝试使用 cypress 验证,有可能在悬停完成之前执行测试,并且使用 cypress 它会等待它:
it("Table rows hover styles should be correct", () => {
cy.get("table>tbody>tr").each(($el, index, $list) => {
$el.trigger("mouseover");
$el.should('have.css', 'background-color', 'rgb(242, 242, 242)');
});
});
推荐阅读
- python - Python中的for循环,更改它正在循环的列表
- c# - 无法在 Inspector 中更改 OnClick 函数参数
- javascript - How can I programatically calculate quantities based on length of material?
- angular - Karma 在 Angular/Cordova 项目上编译错误 - 找不到名称“X”(“FileError”、“Entry”、“DirectoryEntry”等)
- ms-access - Export a query with parameters as a .csv
- python - Checking the elements of a list for multiple strings
- android - Android Library Compiles Against JDK 8
- c# - MVC Core Dependency Injection: Interface-Repository Generic Parameter Error
- swift - 如何包装函数 try catch 以便强制 unwrap nil 不会使应用程序崩溃?
- c - in this example how do i print the sequence only once? (recursive function)