Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
Cypress: obtenga el elemento secundario del padre basado en otro elemento secundario

tengo 2 div colapso

 <div class="collapse> <div class="title">Apple</div> <item>Apple 1</item> <item>Apple 2</item> // get this item <item>Apple 3</item> </div> <div class="collapse> <div class="title">Samsung</div> <item>Samsung 1</item> <item>Samsung 2</item> </div>

Cómo puedo obtener una lista de elementos por título de clase de esta manera:

 cy.get('.collapse').within(() => { if (cy.contains('.title', 'Apple') { cy.get(item).eq(1).... // handle item second of apple } });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede especificar qué .collapse desea por el contenido de sus hijos

 cy.contains('.collapse', 'Apple') // gets the 1st collapse element where child has "Apple" text .find('item').eq(1) // within that, get the 2nd <item> .should('have.text', 'Apple 2')

Si su HTML real es más complicado y desea comenzar con el elemento de título,

 cy.contains('.title', 'Apple') // get the title child with "Apple" text .parent() // move up to div.collapse .find('item').eq(1) // within that, get the 2nd <item> .should('have.text', 'Apple 2')

o hermanos navegación

 cy.contains('.title', 'Apple') // get the tile child with "Apple" text .siblings('item').eq(1) // 2nd item sibling .should('have.text', 'Apple 2')
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!