Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
How to update an alias in cypress

I am not sure if I am using this correctly in cypress. What I want to do is update my alias @priceValue so I can use the updated alias later on.

This is what I mean logic wise:

1: Take the text and give it an alias of priceValue 2: Check price value to make sure it contains a string and then (and here is the issue)-> the alias is updated to a fraction by converting. string to a fraction

How do I update the alias so it's now the converted fraction?

priceElements.priceButton().first().invoke("text").as("priceValue");

cy.get("@priceValue").then((priceValue) => {
        expect(priceValue).contains("/");
        math.fraction(priceValue);
})
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can also just change it, no need for a new alias

priceElements.priceButton().first().invoke("text")
  .should('contain', '/')
  .as("priceValue")

cy.get("@priceValue")
  .then(priceValue => math.fraction(priceValue))  // modify
  .as("priceValue")                              // re-save

cy.get("@priceValue")
  .invoke('toString')
  .should('not.contain', '/')                    // different value
about 4 years ago · Juan Pablo Isaza Relatório

0

You can check this blog out, it discusses in detail how to update an alias - https://ronvalstar.nl/updating-a-cypress-alias.

An easier way would be to wrap the value and create a new alias.

priceElements.priceButton().first().invoke("text").as("priceValue")

cy.get("@priceValue").then((priceValue) => {
  expect(priceValue).contains("/")
  cy.wrap(math.fraction(priceValue)).as("newPriceValue")
})

cy.get("@newPriceValue").then((newPriceValue) => {
  cy.log(newPriceValue)
})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda