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

172
Vistas
assign the value returned from .invoke() into a variable in Cypress

i am using the following code to get a text value from a < td > :

 let serviceName;
    cy.get('tr').eq(1).then(row => {
        cy.wrap(row).find('td').eq(1).invoke('prop', 'innerText').then(val => { serviceName = val });
    })

its working fine on some of pages and not on some others with the same table type/class/etc.. front end is built with Angular

using the same code like this also fails :

let serviceName;
    cy.get('tr').eq(1).find('td').eq(1).invoke('prop', 'innerText').then(val => { serviceName = val });
    })
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use aliases for this.

cy.get('tr')
  .eq(1)
  .find('td', {timeout: 5000})
  .eq(1)
  .should('be.visible')
  .invoke('prop', 'innerText')
  .as('text')

cy.get('@text').then((text) => {
  //access text here
})
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