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
Is it possible to store PART of the URL in to a variable or somehow using cypress and use it later?

i need to store the url from my website in to an URL and use part of it for an API call

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

0

...coming from the comments, I leave an answer here:

With version 6.0.0, Cypress introduced a new command: .intercept().

.intercept() allows you to manage the behavior of network requests. It supports fetch, it can intercept both request and response of your app API calls and so much more, official docs here.

Related to your case, make sure you declare your intercept command before the proper fetch action, let's say on the top of the test. Then, simply call it below in the body of the test by its alias:

cy.intercept('GET', '/project/*').as('myObject')

// ...


cy.wait('@myObject').its('response.body.data.id').then(objUUID => {
// here is your uuid
   cy.log(objUUID) 
})

Note, that any other action related to this uuid should be done inside above callback: .then(objUUID => {}). In case you need it shared between different tests, then intercept your request inside .beforeEach() hook and assign the uuid in a context shared variable, however, this is a bad practice (more about aliases and variables, 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