Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get value input text vue using cypress

thank you for reading my question.

I want to ask about how to get value some input text who that value set by virtual dom/data binding in react/vue or maybe another lib/framework.

In my mind, a cypress is a tool for e2e testing. so that's why we can't get this value. I also check the component that I want to get by inspecting that element, and I can't get some attribute for getting my value.

screen shoot of question get value input text vue using cypress

idk but what should i do but i need to get this value. please tell me if you know this answer.

Thank you

like image 798
ikbal maulana Avatar asked Dec 19 '25 21:12

ikbal maulana


1 Answers

You can get it by using the invoke('val') method, something like:

cy.get('#input_text_employee_name')
  .invoke('val')
  .then((val) => {
    cy.log(val) //prints [email protected]
  })

You can also apply an assertion with should('have.value') like this:

cy.get('#input_text_employee_name').should('have.value', '[email protected]')
like image 52
Alapan Das Avatar answered Dec 22 '25 12:12

Alapan Das



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!