how to compare the elements of two lists #14642
Replies: 2 comments 2 replies
-
@fargonmer check out https://glebbahmutov.com/cypress-examples/6.3.0/commands/assertions.html#expect example |
Beta Was this translation helpful? Give feedback.
0 replies
-
<ol id="first">
<li>Apples</li>
<li>Oranges</li>
<li>Melons</li>
<li>Grapes</li>
</ol>
<ol id="second">
<li>Grapes</li>
<li>Oranges</li>
</ol> const firstList = []
const secondList = []
// let's get the first list of strings
cy.get('#first li').each(($li) => {
firstList.push($li.text())
})
cy.get('#second li')
.each(($li) => {
secondList.push($li.text())
})
.then(() => {
// when this callback runs, both lists will be populated
expect(firstList).to.include.members(secondList)
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
bahmutov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
i would like to write a syntax that compare the array2 values(son2) is preset in array1(son1)
Beta Was this translation helpful? Give feedback.
All reactions