How to clear text in text field ?
>> In protractor, we can clear the value in textbox using clear().
>> clear() will not return any value.
Please check below code script:
First write xpath with help of DOM
clear() in protractor |
describe('Protractor - clear()', function () {
it('Code script to use clear() in protractor', function () {
browser.get("https://keeplearners.blogspot.com/2018/03/Angular-elements.html");
var textElement = element(by.model('name'));
enterText(textElement, "Keeplearners");
clearTextBox(textElement);
});
function enterText(element, text) {
element.sendKeys(text).then(function () {
console.log("Entered " + text + " in text box");
});
}
function clearTextBox(element) {
element.clear().then(function () {
console.log("Cleared text in text box")
});
}
});
No comments:
Post a Comment
Please comment below to feedback or ask questions.