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

539
Visualizações
How to get an element value that is not showing in html code with Cypress?

this is the code of my element

<input type="text" class="nameOfClass" id="someid" name="somename" maxlength="255" placeholder="justholder" ng-model="model" tooltip-placement="top" tooltip-trigger="mouseenter" tooltip-animation="false" style="">

as you can see there is no attribute value, but I can clearly see that there is text in that text field in web app I am trying to automate.

So my problem is, that I don't know how to get value of the text field. I've tried google chrome inspector to find where is the value but without any luck. Somewhere I read, that caching can causing this problem, but in the network console I can see the values in request response.

Thanks

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

0

Assuming that you want to get the value written in the text field, you can get it by invoking val.

cy.get('#someid')
  .invoke('val')
  .then((value) => {
    cy.log(value) //logs the value
  })

If you want to apply any assertion on the value, you can:

cy.get('#someid').should('have.value', 'your-value')
about 4 years ago · Juan Pablo Isaza Relatório

0

If you are referring to type="text", that's not the text the user types in - it's an attribute that tells the input what values to allow.

You can also have type="number", type="date", type="color", etc

Checking that input is of type "text" would be done with this,

cy.get('input#someid').should('have.attr', 'type', 'text')

Checking the value property would be done like this

cy.get('input#someid')
  .type('entering a value')     // there's nothing in value yet
  .should('have.value', 'entering a value')
  
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