Using 2 conditions with an IF statement in Cypress

Hello I’m trying to run the following code but somehow it does not work. The same code will work if I simply separate the IF statement in 2 and nest it.
My intention is to select only one element from the dropdown list but buy using includes, I’m getting 2 results; that is why I was trying to add an extra condition to it.

    cy.get(".ui-menu-item").each(($el) => {
      if ($el.text().includes("Netherlands" && $el.text().length === 11)) {       

Do you happen to know why that is? is there a better way of doing this? thank you

83 thoughts on “Using 2 conditions with an IF statement in Cypress”

Leave a Comment