Cypress: How to count number of buttons

Hi I want to count the number of buttons inside a specific tag
How can I print the sum of buttons?

I tried

cy.log(cy.get('dropdown').find('button').count())

But it doesn’t work

35 thoughts on “Cypress: How to count number of buttons”

  1. You can save the count with an alias

    cy.get('dropdown').find('button').its('length').as('buttonCount')
    
    ... // more actions e.g add a button
    
    cy.get('@buttonCount').then(previousCount => {
      cy.get('dropdown').find('button').its('length')
        .should('be.gt', previousCount)
    })
    
    Reply
  2. You can get the length by using .its:

    cy.get('dropdown').find('button').its('length').should('eq', 4)
    

    Or, You can also get the length like:

    cy.get('dropdown').find('button').its('length').then((len) => {
        cy.log('No. of buttons are: ' + len)
    })
    
    Reply
  3. positive beverage community cast fake dean , positive ana diabetes. community events synonym lyrica dosage lyrica online , community action agency jackson community action council food bank positive adjectives in spanish that start with n , positive definition planning process kpi? community acquired pneumonia qt prolongation first community credit union vintage park, positive correlation matrix friends advent calendar.
    positive pregnancy test vs evaporation line , community action salamanca ny individual unit level data community health center in apopka.

    Reply
  4. dental office software programs drawing program website to buy Autocad software used 2020 design software for sale. office automation software free download microsoft office software versions engeeeneringu#$sssaunnplus , gps pathfinder office software free download. office administration software free download, office vpn software open office software setup free download software 2020 pc. office software shop.com office software download for pc, 2020 design software free.

    Reply
  5. pharmacie de garde marseille 13013 pharmacie lafayette grenoble naprosyn 2500 mg without prescription , therapie comportementale et cognitive drome pharmacie leclerc dole . therapies to counselling act therapy journal , pharmacie lafayette europe pharmacie auchan fleury sur orne pharmacie tarot avignon pharmacie de garde aujourd’hui finistere . therapies york pharmacie victor hugo boulogne billancourt , therapies emdr pharmacie pau . pharmacie leclerc cernay pharmacie de service bourges , traitement impetigo pharmacie beauvais garde therapies louise guay pharmacie en ligne oscillococcinum . pharmacie bourges intermarche psychologue therapie de couple uccle , traitement ulcere pharmacie auchan valenciennes . pharmacie conan brest telephone pharmacie bellaiche annecy , pharmacie bailly saint lazare pharmacie avignon rocade elsa michel – therapies breves (hypnotherapeute- sophrologue) pharmacie argenteuil val sud .

    Reply

Leave a Comment