I’m trying to test whether an attribute that is shared by 3 elements has one of several values. Here’s the html:
<div class="wrapper">
<a title="value 1"</a>
<a title="value 2"</a>
<a title="value 3"</a>
</div>
I need a way to assert that the title
attribute of all three elements will have one of the 3 values, because their order might change in the future but I just need to make sure that they’re there.
Here’s what I’ve tried but didn’t work for me:
cy.get('.wrapper')
.children().as('socialLinks');
cy.get('@socialLinks')
.should('have.attr', 'title').as('title');
expect('@title').to.contain.oneOf('value 1', 'value 2', 'value 3');
I suspect it might need a for-loop
but I can’t wrap my head around how to approach it.