I am trying to get the element count using below method :
cy.log(Cypress.$('tr.dx-row-lines').length)
but it always print 0
while If I use code like below :
cy.get("body").then(($el) =>{
cy.log ($el.find("tr.dx-row-lines").length)
}
it print 4
Because I need to break a for loop if rows found so I can not use 2nd way,
Please guide me
Cypress.$('tr.dx-row-lines').length is evaluated immediately because it is a sync method. so it's evaluating before other Cypress code is ran.
I suggest reading the entirety of our Introduction to Cypress guide. Specifically the section on mixing async and sync code.
Issues in our GitHub repo are reserved for potential bugs or feature requests. This issue will be closed since it appears to be neither a bug nor a feature request.
We recommend questions relating to how to use Cypress be asked in our community chat. Also try searching our existing GitHub issues, reading through our documentation, or searching Stack Overflow for relevant answers.