如何检查没有固定宽度元素是否有固定宽度
如果我这样做的话。cy.get('element').should('have.css', 'width', 'auto)它将失败,因为它将检查元素实际设置宽度。
发布于 2019-11-14 02:06:44
因为'have.css‘在幕后使用JQuery的css(...)函数(它计算确切的宽度),所以你必须使用window.getComputedStyle
const haveStyle = (name, value) => ($el) => {
expect($el[0].ownerDocument.defaultView.getComputedStyle($el[0])[name]).eq(value)
}
cy.get('.el').should(haveStyle('width', 'auto'))https://stackoverflow.com/questions/58816920
复制相似问题