Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

347
Vistas
Cypress: la matriz está vacía después de salir del bloque .then

Estoy tratando de almacenar algunas cadenas dentro de una matriz.

 it('Action -> delete -> check list of camapaigns to delete',function(){ let campArr=[] cy.get('md-checkbox').then((box)=>{ for(let i=1;i<box.length;i++){ cy.get(`.md-body > :nth-child(${i}) > :nth-child(3)`).then(($el)=>{ let elToText=$el.text() campArr[i-1]=elToText }) } }) cy.log(campArr.length) cy.get('md-checkbox').eq(0).click() cy.get('.btn-group>button').eq(0).click() cy.get('.dropdown-menu-left > :nth-child(3) > .ng-binding').click() cy.log(campArr[0]) for(let i=0;i<campArr.length;i++){ cy.get(`div.ng-scope > ul > :nth-child(${i+1})`).should('contain.text',campArr[i]) cy.log('checked') } })

Pude almacenar las cadenas dentro de la matriz, pero después de salir del bloque .then, la matriz está vacía. ¿Qué debo hacer para mantener los valores dentro de la matriz?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

La forma más fácil de hacer que el acceso a campArr sincrónico con la asignación es usar una devolución de llamada:

 it('Action -> delete -> check list of camapaigns to delete',function(){ let campArr=[] cy.get('md-checkbox').then((box)=>{ for(let i=1;i<box.length;i++){ cy.get(`.md-body > :nth-child(${i}) > :nth-child(3)`).then(($el)=>{ let elToText=$el.text() campArr[i-1]=elToText }) } }) cy.log(campArr.length) cy.get('md-checkbox').eq(0).click() cy.get('.btn-group>button').eq(0).click() cy.get('.dropdown-menu-left > :nth-child(3) > .ng-binding').click().then(() => { cy.log(campArr[0]) for(let i=0;i<campArr.length;i++){ cy.get(`div.ng-scope > ul > :nth-child(${i+1})`).should('contain.text',campArr[i]) cy.log('checked') } } })
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda