设置使用量角器的角度模式 [英] Setting an Angular model using Protractor

查看:133
本文介绍了设置使用量角器的角度模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图模仿用户的故事在我的网站用量角器。

用户必须键入一个使用自动完成的输入。在现实生活中,用户可以键入输入一些文字,然后,用她的鼠标或多个天然她DownArrow中文键选择正确的命题。

问题是,我似乎无法模拟与量角器。 element.sendKeys只是不允许你这样做。我曾尝试在十几个不同的方式,它充其量产生未predictable结果。

所以我想操纵NG-模型直接behing我的输入。是否有访问它从量角器和通话功能/设置属性的元素范围的方法是什么?

下面是我的问题的一个简化版本:

查看:

 < D​​IV NG控制器=myController的>
  <输入ID =我输入NG模型=基于myModel/>
< / DIV>

控制器:

  myModule.controller('myController的',['$范围',函数($范围){
   $ scope.myModel =;
   // [...]
 }]);

E2E量角器测试:

 描述了(设置基于myModel为固定值功能(){
  它(应该设置基于myModel为测试值',函数(){
    VAR myInput =元素('我输入');
    // 怎么办?
  });
});


解决方案

在这样的回答:<一href=\"http://stackoverflow.com/questions/19599450/how-to-select-option-in-drop-down-protractorjs-e2e-tests\">How选择在下拉protractorjs端到端测试选项

他们使用这样的: .sendKeys(protractor.Key.ARROW_DOWN); 发送下箭头

这值得一试。

I'm trying to emulate a user story on my website with Protractor.

The user has to type in an input that uses auto-completion. In real life, the user has to type some text in the input, then select the right proposition with either her mouse or more naturally her downarrow key.

The problem is that I can't seem to simulate that with Protractor. element.sendKeys just does not allow you to do that. I have tried in a dozen different manners and it yields unpredictable results at best.

So I would like to manipulate the ng-model behing my input directly. Is there a way to access the scope 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 Protractor test :

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

解决方案

In this answer: How to select option in drop down protractorjs e2e tests

They use this: .sendKeys(protractor.Key.ARROW_DOWN); for sending DOWN arrows.

It worth a try.

这篇关于设置使用量角器的角度模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆