2

enter image description here

In an automation code, I want to fill the text-box with a number greater than 0. setvalue() doesn't work. A user would have to click on the up arrow (see picture) to make the text-box editable. How can I make this happen?

 <input aria-invalid="false" autocomplete="off" class="MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputMarginDense MuiOutlinedInput-inputMarginDense" id="yieldGoal" name="yieldGoal" placeholder="0.00" type="number" min="0.01" step="0.01" data-test="new-program-form__yield-goal-input" value="0.00"> 

So far I have attempted to set the attributes step, value with a value large than 0.0. It did not work.

$('#yieldGoal').setAttribute('step', "2.0")

Increment the value in the text-box

2 Answers 2

1

Please use val to set the value of an input element.

$('#yieldGoal').val("2.0");

Hope this will solve the issue.

3
  • Did not work. This could be due to wdio. It has its own function setValue(). Why is do I see this error in the Chrome browser console?Uncaught TypeError: $(...).val is not a function at <anonymous>:1:55
    – RSSregex
    Commented Nov 12, 2019 at 12:16
  • I think you are missing JQuery, try to add jQuery library and the run this code. Commented Nov 12, 2019 at 12:54
  • Okay. Adding another observation. The UpArrow and DownApprow key inc/dec the value. How about calling browser.keys(UpArrow)?
    – RSSregex
    Commented Nov 12, 2019 at 14:42
1

if this is texbox and you use jQuery try

$('#yieldGoal').val("2.0")

Not the answer you're looking for? Browse other questions tagged or ask your own question.