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

前端 未结 5 1986
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 19:56

    if you want more flexible and have a dynamic result use this.

    cy.get('.listings-grid')
      .find('.listing')
      .then(listing => {
        const listingCount = Cypress.$(listing).length;
        expect(listing).to.have.length(listingCount);
      });
    

提交回复
热议问题