Hi All,
I am using below Script to clear a Text Box in protractor. However the Text Box is not getting cleared. It gets appended with whatever i pass in SendKeys() function. Kindly help me on this.
Script used is as below
browser.element(by.xpath("")).clear();
browser.sleep(2000);
browser.element(by.xpath("")).sendKeys("100");
This Script does not works. Please help
It would be better to create a question on the stack overflow. What exactly doesn't work? What error do you get?
We are having the same issue. Our suite started failing (maybe it's connected to chromedriver 2.43), input.clear() method just stopped working, no error message
We are having the same issue. Our suite started failing (maybe it's connected to chromedriver 2.43), input.clear() method just stopped working, no error message
Check if you have a a onblur javascript execution. I've been having issues as well with clearing an input field which contains a validation function that runs onblur
Experiencing the same issue; clear method is just not working. Rolling back to using ChromeDriver 2.42 works.
We are having the same issue. Our suite started failing (maybe it's connected to chromedriver 2.43), input.clear() method just stopped working, no error message
Check if you have a a
onblurjavascript execution. I've been having issues as well with clearing an input field which contains a validation function that runs onblur
@sergioalen Maybe I have the same. How did you fix this?
.....sendKeys(protractor.Key.SHIFT, protractor.Key.END, protractor.Key.BACK_SPACE, <data>?
You should add explicit waiter for checking that this element is clickable before use clear.
@CrispusDH waiting does not solve the onblur problem
@kovacsbalu , you are right. In my case after updating to Chrome 70 I have started to get errors before clear method. But before clear method I have already had explicit waiter on visibility of element. When I change it to clickable condition the errors gone. So, just in case...
Still failing with ChromeDriver 2.44.
I've got the same issue, too. Rolling back to using ChromeDriver 2.42 works. But not working with ChromeDriver 2.43 +
We are having the same issue. Our suite started failing (maybe it's connected to chromedriver 2.43), input.clear() method just stopped working, no error message
Check if you have a a
onblurjavascript execution. I've been having issues as well with clearing an input field which contains a validation function that runs onblur@sergioalen Maybe I have the same. How did you fix this?
.....sendKeys(protractor.Key.SHIFT, protractor.Key.END, protractor.Key.BACK_SPACE, <data>?
My issue was that before the update, I was clearing an input with clear() then entering a new value which with the new update clear() now focuses out the input field for some reason, triggering the unblur function. To stop this from happening I created a helper function to delete the values on the input field using backspace before entering the new value without focusing out the input field:
export function backspace(inputEl: ElementFinder, spaces?: number) {
return inputEl.getAttribute('value').then((text) => {
let spacesToGoBack = spaces || text.length;
do {
inputEl.sendKeys(Key.BACK_SPACE);
spacesToGoBack--;
} while (spacesToGoBack > 0);
});
}
Then in the test I would use this like this:
backspace(inputEl).then(() => inputEl.sendKeys(price));
I'm not sure if that was the actual issue, but it worked for us.
I am facing the same issue, and in one specific case, even with chromedriver 2.42, when running the test in headless mode, the clear method does not work, but when running with headless mode Off, then it works.
It may be worth mentioning that I'm testing a React app, which uses react-final-form for the forms where I face this issue.
Try this to clear the field:
await elem.sendKeys( protractor.Key.chord(protractor.Key.CONTROL, "a"))
await elem.sendKeys( protractor.Key.chord(protractor.Key.DEL))
Most helpful comment
Check if you have a a
onblurjavascript execution. I've been having issues as well with clearing an input field which contains a validation function that runs onblur