1
cy.get('div[id="base-table-\[object\ Object\]-body"] > .MuiGrid-root, .jss505').should('have.length', 10)

How to make a check <=10 ? Maybe to.have.length.most() DOM

<div id="base-table-[object Object]-body">
    <div class = "MuiGrid-root jss505"> </div>
    <div class = "MuiGrid-root jss505"> </div>
    <div class = "MuiGrid-root jss505"> </div>
    <div class = "MuiGrid-root jss505"> </div>
    <div class = "MuiGrid-root jss505"> </div>        
</div>
Linkin
  • 11
  • 2

3 Answers3

0

You can enhance the assertion as follows

cy.get('div[id="base-table-\[object\ Object\]-body"] > .MuiGrid-root, .jss505')
  .should('have.length.lt', 11)
Fody
  • 23,754
  • 3
  • 20
  • 37
0

You can use these assertions:

cy.get('div[id="base-table-[object Object]-body"] > .MuiGrid-root, .jss505')
  .its('length')
  .then((len) => {
    expect(len).to.be.lte(10)
  })

Or,

cy.get('div[id="base-table-[object Object]-body"] > .MuiGrid-root, .jss505')
  .its('length')
  .then((len) => {
    expect(len).to.be.within(0, 10)
  })
Alapan Das
  • 17,144
  • 3
  • 29
  • 52
0

You can use the following callback assertion

cy.get('div[id="base-table-[object Object]-body"] > .MuiGrid-root, .jss505')
  .should($els => expect($els.length).to.be.lte(10))

Using .should() instead of .then() gives you command retry in async situations.