I have a test written in Java using Selenium Webdriver which visually clears a text field written in Angular 2 but Selenium doesn't actually clear the field in the DOM.
I need to get an alert from the text field that says that you can't create an empty title, and that alert doesn't appear because the DOM still says that there is a title even though Selenium supposedly cleared the field:
ng-reflect-length="10"
ng-reflect-model="New Survey"
If it actually did clear, the DOM should not include the above angular code.
I originally tried using the correct format of Java Selenium to clear:
public void clearTextField(){
webElement.clear();
}
And this will visually clear the text field, but those Angular 2 attributes and values do not disappear in the DOM as they should. This causes the character counter in the text field to remain at 90 chars instead of what it should be at 100 chars. If it was 100 chars, I would get my alert.
The above Angular 2 attributes and values will reflect a sendKeys change if I:
public void sendKeysToTextField(String inputText){
webElement.sendKeys(inputText);
}
But still, the DOM doesn't update when clearing the text field.
I have a hacky workaround, which forces a RobotUtility to backspace and it needs coordinates to locate the page. But this only works locally.
Please help! Thank you.