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

137
Vistas
Use a wraped variable in the type() function. Cypress

I'm trying to save a string with:

        cy.get('#accessInfoText').invoke('text').then($wholeText => {
            let pattern = /(?<=code: ).{10}/i;
            let number = $wholeText.match(pattern);
            cy.wrap(number).as('accessCode');
            cy.log(number);                           // AsTE5sOlJU 
        });

Later on, in the test, I need it to type it into an input field:

     cy.get('@accessCode').then(code => {
            cy.log(code);                           // [AsTE5sOlJU] 
            cy.followLabel('Access code').type(code)
        });

And my problem is that cypress converts it to an object. Which is not accepted by the .type function. enter image description here

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

0

The line let number = $wholeText.match(pattern); returns an array of all matches, even if you only have one.

Try

let number = $wholeText.match(pattern)[0];  // take first match only

If there's a possibility that there's no matches, you would need to expand it to avoid a runtime error.

const matches = $wholeText.match(pattern)
const number = matches.length ? matches[0] : null
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