In Cypress how to count a selection of items and get the length?

前端 未结 5 2001
Happy的楠姐
Happy的楠姐 2020-12-29 19:15

I\'m starting to learn Cypress. I have a 4 row table (with a class of datatable). I can verify the number of rows this way:

cy.get(\'.datatable\').find(\'tr\         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-29 20:04

    Found a solution, This works to check a count of items:

    cy.get('.datatable').find('tr').should('have.length', 4)
    

    This does not work with the Cypress.$() method of notation.

    Reference: https://docs.cypress.io/guides/references/assertions.html#Length

提交回复
热议问题