I think you are looking for protractor.Key.BACK_SPACE
.
element(by.id('textfield_13')).sendKeys(protractor.Key.BACK_SPACE);
I think you are looking for protractor.Key.BACK_SPACE
.
element(by.id('textfield_13')).sendKeys(protractor.Key.BACK_SPACE);
Hello stackoverflow community!
I have this piece of HTML code:
<div class="ds-u-clearfix ds-l-col--auto">
:: before
<label class="ds-c-label ds-u-font-weight--normal ds-u-margin-top--1" for="textfield_13" id="textfield_label_14">
<span class="">Day</span>
</label>
<input class="ds-c-field ds-c-field--day ds-c-field--error" id="textfield_13" type="number" max="31" min="1" name="day" aria-describedby="datefield_label_10" value="01">
:: after
</div>
I’m working on test automation using protractor and I need to clear an input field that has a value already. Protractor’s .clear() doesn’t work (literally has no effect). So I though I could inject a script to the devtools’ console to change the value. But when I do that (eg $elem.value = ""
) it looks like it’s clearing the input, but if I start typing another value, the previous one appears again
How do I clear the value of the input permanently?
$elem.value = "";
$elem.value = null;
$elem.defaultValue = "";
$elem.setAttribute ("value", "");
// and many more
Again, whenever I do any of this^^ it looks like the input is cleared, but then the value comes back if I start typing
Thanks for reading to the end 🙂
Frankly I don’t care how to solve this – from devtools or from protractor itself, so any ideas are appreciated. I was thinking about doing
you can use document.getElementById(“textfield_13”).value = “” to clear your input value
Does this answer your question?
@ShivanshuGupta if you read the question, you’ll notice I tried that already
@Gerard the entire html page has no references to
I’ll get back to you in a bit, thanks for the answer @jortega