I need to check if all images on my page have the Alt attribute. I thought doing the following would do that but it doesn't check things correctly and just gives me an everything is good when I know it's not. cy.get('img').should('have.attr', 'alt' );
Is there an easy solution other than many go through the page and build a selector for every image?
To check each element, you can use .each
:
cy.get('img').each($el => {
cy.wrap($el).should('have.attr', 'alt')
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.