无法使用 Cypress.io 测试背景颜色,在运行 cypress 测试时会抛出以下错误; CypressError:重试超时:actual.equals 不是函数。通过安装的 chai-colorsnpm install chai-colors
并在 /support/index.js 下添加了以下内容
import chaiColors from 'chai-colors'
chai.use(chaiColors)
柏树测试如下:
describe("Background Color test", () => {
//before(() => {
// cy.visit('https://sometesturl.com')
// })
it.only('Verify the backgroud color, this should work', () => {
cy.visit('https://sometesturl.com')
cy.get('#footer')
.should('colored', '#f2e47d')
.and('be.colored', '#f2e47d')
})
})
我尝试过使用与颜色 #f2e47d 相对应的“eq”和“rgb”值。在以下链接中,来自 cypress.io 的“brian-mann”确认“match”始终适用于正则表达式。https://github.com/cypress-io/cypress/issues/58 https://github.com/cypress-io/cypress/issues/58现在测试已成功断言页脚区域中的背景颜色值。
describe("Background Color test", () => {
it.only('Verify the backgroud color, this should work', () => {
cy.visit('https://sometesturl.com')
cy.get('#footer')
.should('have.css', 'background-color')
.and('eq', 'rgb(242, 228, 125)')
})
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)