Reputation: 357
Using Karate I am not able to clear field (input, textarea) properly:
<input name="title" id="title" class="form-control" placeholder="e.g. My MacBook Key" value="">
1) insert to input field with id=title is OK.
retry().input('#title', 'something')
Everything is written to field. OK.
2) I need to clear the field. I use following:
retry().clear('#title')
Field seems to be deleted after this action (text in input field is not visible).
3) But when I use input again
retry().input('#title', 'new')
In field is displayed: somethingnew. It seems that first string was not properly deleted and strings are merged together. It happens for input/text area fields.
Could you help me please? Any idea?
Thank you.
Upvotes: 2
Views: 2693
Reputation: 21
First we need to focus on the web element
Then clear the input field/text area on the browser, use clear()
To clear the value from DOM, we are using Key.CLEAR
Finally insert your value/custom value into the input field as below
Upvotes: 2
Reputation: 58068
Try using value()
or JS directly instead of clear()
:
* value('#title', '')
Or:
* script('#title', "_.value = ''")
Upvotes: 3