I haven't been able to find anything on this topic, so I figured I would ask.
I'm currently writing E2E tests on my Angular 5 application. E2E is being performed by Protractor as configured in a default Angular CLI generator project. I need the ability to change the value of a text input field from within my E2E tests.
My current code.
...
it('should submit report.',() => {
page.setField("100");
...
The above references this class and method
import { browser, by, element } from 'protractor';
export class Page {
setField(text: string): Page {
let field = element(by.id('myField'));
field.sendKeys(text);
return this;
}
...
and my html.
<input id="myField" decimal="16" dataLoadedEvent="{{formatData}}" [(ngModel)]="rm.dataField" class="form-control input-sm">
It's very simple. Obviously I have generalized it for consumption... But hopefully it still gets the point across.
Things to note:
If I remove the following from the html input field, .sendKeys() works
decimal="16" dataLoadedEvent="{{formatData}}" [(ngModel)]="rm.dataField"
If I just remove
decimal="16" dataLoadedEvent="{{formatData}}"
sendKeys() still doesn't work. This means that the issue is with the [(ngModel)] binding that occurs on the field. Not with my custom decimal format directive.
So, my question is, what do I need to do to make .sendKeys() work with fields that are bound using [(ngModel)]?
Any help would be appreciated.