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

RSSregex
  • 179
  • 7

2 Answers2

1

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

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

Hope this will solve the issue.

Sohail Ashraf
  • 10,078
  • 2
  • 26
  • 42
  • 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 :1:55 – RSSregex Nov 12 '19 at 12:16
  • I think you are missing JQuery, try to add jQuery library and the run this code. – Sohail Ashraf Nov 12 '19 at 12:54
  • Okay. Adding another observation. The UpArrow and DownApprow key inc/dec the value. How about calling browser.keys(UpArrow)? – RSSregex Nov 12 '19 at 14:42
1

if this is texbox and you use jQuery try

$('#yieldGoal').val("2.0")
IgorK
  • 148
  • 8