-
Notifications
You must be signed in to change notification settings - Fork 2.3k
WebElement.clear() Does Not Update Model #301
Comments
Good catch. FYI as soon as you send further keys, the model updates. |
Not sure what to do about this one, whatever the driver does to clear is not sending any trigger for Angular to $digest. Not seeing it as a huge issue so punting to post 1.0. |
Hi! Is there any workaround that could be used until it is fixed? I've tried to use sendKeys() with an empty string but it did not work. Edit: |
I have this exact same issue. For example, I'm testing my login form validation and sending a clear() to the password field in order to confirm the 'Password required error' message appears. I've tried calling clear() followed by sendKeys('') with an empty string but that doesn't trigger the model binding. Is there any workaround I've missed? |
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:
|
Genius! That works a treat. Thank you! |
no problem. glad it worked for you! |
@wlingke Just used that - good trick! |
glad to be of help :) |
Hello there guys, Hm i have probably a little bit different problem. When i click the button the function that is executed must clear the model object (the functionality is unit tested so it's working). If there is something wrong that i'm doing please tell me. |
I'm no longer seeing this issue, and have pushed a test verifying the correct behavior. Please open a new issue if it's still occurring for you! |
@wlingke thank you, you are genius |
@wlingke thanks from 2017. I still have this issue on angular 2. |
@EugeneSnihovsky Are you having problems with clear in a pure angular 2 application? I am having issues in a hybrid app with validation not triggering when using clear but wasn't sure if i have broken something or if it was related to hybrid application. |
me too! on ng2 |
Still having this issue in 2017. On an input containing 'abc', .clear() followed by .sendKeys('d') on the empty input field and results in 'abcd' in angular's model using reactive forms. @wlingke's solution works only as long as you don't try to run it on an operating system where CTRL is not set to the modifier key. It's probably safer to run protractor.Key.BACK_SPACE * length of input value for now. |
@wlingke thanks from 2018, lol. Still having this problem on Angular 5 when I try doing:
|
Ok I've had to resort to a more complex workaround, but it's a lot more reliable. I've had no false test failures with this.
|
I tried your solution @evanjmg and I'm still stuck with the focused input. Not cleared, no new content append. |
I can confirm this is still an issue with Angular 7.2.3 and Protractor 5.4.0 on 73.0.3683.103. |
@wlingke thanks much, your solution worked for me too. |
Hi @juliemr I can confirm, that
|
@wlingke Thanks a lot! 2019 and this is still the way to go :) |
I had a similar issue recently. The workaround is to select all the existing text, use backspace to clear the text |
Guys.. If the above solutions does not work for you, then try below. It works.. |
Noticed this problem when we tried to test some validation. It all works manually but using setKeys and clear doesn't seem to affect Angular to mark the input as touched or dirty. I wonder if there validation component we are using is loaded too slowly and isn't actually loaded by the time the test has filled out the form, it's only 2 inputs in my case. I'll run a delay test tomorrow and see if that fixes it. |
Calling WebElement.clear() on an input element does not appear to update the associated model.
View:
Spec:
The text was updated successfully, but these errors were encountered: