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

117
Visualizações
How to use text from html-element in others non-cypres functions?

I need to get text from html element to use it in other checking.

But this checking must be done elsewhere later, not inside function of text getting.

That's why such variant as

> cy.get('#at__title').invoke('text').then((storedValue) => {
>    storedValue
> })

doesn't suite, because I can use text only inside then.

Also I tried to use

> cy.get('#at__title').invoke('text').as('element_text')
> this.element_text

but console log shows this.element_text as undefined.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Using an alias is correct cy.get('#at__title').invoke('text').as('element_text') but to access the value like this

this.element_text

requires the test to not be an arrow function.

Use this format

it('test something', function() { 
  this.element_text

Or use the longer syntax for accessing an alias

cy.get('@element_text').then(element_text => { 
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