question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebElement.clear() Does Not Update Model

See original GitHub issue

Calling WebElement.clear() on an input element does not appear to update the associated model.

View:

<input ng-model="foo">
<div>{{foo}}</div>

Spec:

it("should update the model", function(){
    var input = element(by.css("input"));
    input.sendKeys("bar");
    input.clear();
    expect(element(by.css("div")).getInnerHtml()).toBe(""); // Fails, because it's still "bar"
});

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:2
  • Comments:26 (8 by maintainers)

github_iconTop GitHub Comments

35reactions
wlingkecommented, Jan 17, 2014

I had a similar issue with a directive I was using and sendKeys not updating the model. This solution worked for me though I am not sure if it will work for you all:

field.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, "a"));
field.sendKeys(protractor.Key.BACK_SPACE);
field.clear();
6reactions
sebastianhaascommented, Apr 11, 2019

I can confirm this is still an issue with Angular 7.2.3 and Protractor 5.4.0 on 73.0.3683.103.

Read more comments on GitHub >

github_iconTop Results From Across the Web

selenium clear() command doesn't clear the element
Here is the issue: I cleared a text field using webelement.clear() method, later while executing next command (click event), the text area I...
Read more >
Will the variable be still referencing the same webelement on ...
No, you will never get stale element, element is only initialized when you do something with it. You can Click, Refresh page, Click...
Read more >
Check Visibility of Web Elements Using Various Types ...
Akin to above methods, we have a method referenced as “isSelected()” which tests if the specified web element is selected or not.
Read more >
How To Type, Retrieve and Clear values from the Text box ...
Interface WebElement consists of a method “sendKeys()” which is used ... sendKeys() method does not clear the existing text of an input box....
Read more >
webdriver.WebElement.clear - Protractor
Schedules a command to clear the value of this element. This command has no effect if the underlying DOM element is neither a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found