Cypress: List

<ul>
  <li>item 1</li>
  <li>item 2</li>
  <li>item 3</li>
  <li>item 4</li>
</ul>
cy.get("li");
cy.get("ul>li");
cy.get("ul").children();
cy.get("li").should("have.length", 4);
cy.get("li").first().should("contain", "item 1");
cy.get("li").eq(0).should("contain", "item 1");
cy.get("li").eq(1).should("contain", "item 2");
cy.get("li").eq(2).should("contain", "item 3");
cy.get("li").eq(3).should("contain", "item 4");
cy.get("li").last().should("contain", "item 4");

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *