Installing an Angular Model Using Protractor

I am trying to emulate user stories on my website using Protractor.

The user must enter an input that uses autocomplete. In real life, the user must enter text into the input, and then select the correct sentence either with the mouse, or, of course, with its help.

The problem is that I cannot simulate this using Protractor. element.sendKeys just doesn't let you do this. I tried a dozen different manners, and this gives unpredictable results at best.

So, I would like to manipulate the ng-model, obeying my input directly. Is there a way to access the volume of an element from Protractor and call functions / set properties on it?

Here is a simplified version of my problem:

View:

<div ng-controller="MyController"> 
  <input id="my-input" ng-model="myModel"/>
</div>

Controller:

 myModule.controller('MyController', ['$scope', function($scope){
   $scope.myModel = "";
   //[...]
 }]);

e2e :

describe("setting myModel to a fixture value", function(){
  it("should set myModel to 'a test value'", function(){
    var myInput = element('my-input');
    // Now what?
  });
});
+4
2

.evaluate(), :

var elm = element(by.model("obj.field"));
elm.evaluate("obj.field = 'test';");

:

elm.evaluate("obj.field").then(function (value) {
    console.log(value);
});
+6

: protractorjs e2e

: .sendKeys(protractor.Key.ARROW_DOWN); DOWN.

.

+4

Source: https://habr.com/ru/post/1536561/


All Articles