Home > Enterprise >  How can I set vue.js input element via JS
How can I set vue.js input element via JS

Time:09-28

I have a input made by vue.js's built-in components. I want to be able to set a value and submit this value to be able to create automated tests. How can I accomplish this?

Currently this is how I set value, but on submit this value is changed with the default data automatically.

    Execute JavaScript    return element.value = "${startDate}"

CodePudding user response:

Simply run dispatchEvent method on the component itself. This will let Vue to set the value that you've entered to the form data

Execute JavaScript    return element.dispatchEvent(new Event('input'));

CodePudding user response:

Creating a new dispatchHandler fixed my problem!

Execute JavaScript    return element.value = "${startDate}"
Execute JavaScript    return element.dispatchEvent(new Event('input'));
  • Related