Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在角度端到端测试中修改阵列模型?_Javascript_Arrays_Angularjs_Testing_End To End - Fatal编程技术网

Javascript 如何在角度端到端测试中修改阵列模型?

Javascript 如何在角度端到端测试中修改阵列模型?,javascript,arrays,angularjs,testing,end-to-end,Javascript,Arrays,Angularjs,Testing,End To End,我有一个angular应用程序,它在控制器中定义了一个表,如下所示: $scope.rowHeaders = ["Revenues","Costs","Profit"]; $scope.data = [[100,230,300,400,500,600,700,800,900,1000,1100,1200], [30,40,50,60,70,80,90,100,110,120,130,140], [70,160,250,340,430,540,630,720,810,900,990,1100]];

我有一个angular应用程序,它在控制器中定义了一个表,如下所示:

$scope.rowHeaders = ["Revenues","Costs","Profit"];
$scope.data = [[100,230,300,400,500,600,700,800,900,1000,1100,1200], [30,40,50,60,70,80,90,100,110,120,130,140], [70,160,250,340,430,540,630,720,810,900,990,1100]];
行标题应用于数据对象中的每一行。它连接到模板,如下所示:

    <tbody>
      <tr ng-repeat="row in rowHeaders track by $index">
        <td>{{row}}</td>
        <td ng-repeat="cellData in data[$index] track by $index">
          <input id="data{{$parent.$index}}_{{$index}}" type="text" class="clsinputboxes" ng-model="data[$parent.$index][$index]" name="data{{$parent.$index}}_{{$index}}" ng-blur="updateColor($parent.$index, $index, data[$parent.$index][$index])" style="background-color: {{color[$parent.$index][$index]}}">
        </td>
      </tr>
     </tbody>
但这实际上不起作用,我得到以下错误:

http://localhost:8000/test/e2e/scenarios.js:17:4
Selector [ng\:model="data[1][1]"] did not match any elements.
然而,代码在不处于测试模式时工作正常,并且使用ng model=“data[$parent.$index][$index]”将模型正确绑定到输入标记中

对于和端到端测试,如何将一些数据输入到表中链接到阵列模型的任何框中

我还尝试了以下方法(尽管我更愿意使用input().enter()):


这会更改框内容,但不会触发updateColor()。我还试着放置e1.blur()-这也不起作用。

我终于能够在Angular的优雅端到端场景中实现这一点

首先,我给了表标签一个id——“Inputable”

然后,场景运行者中的以下人员完成了此操作:
使用(“表#可输入tbody tr:eq(1)td:eq(2)”)。输入(“数据[$parent.$index][$index]”。输入(20)


向帮助我解决这个问题的人大喊。

是否尝试直接更改数据数组中的值?根据我的经验,angular和jQuery并不能很好地结合在一起,所以可以使用$watch或$apply之类的东西,或者显式地更改变量。您甚至可以创建一个自定义指令来侦听更改并将其传输到角度模型。另外:
var-input=$('input');input.val('xxx');input.trigger('input')更改值直接违背了端到端测试的目的,尽管我认为它会测试绑定。如何在端到端测试中获得范围?目前我正在做:
browser().navigateTo('app/index.html')我还尝试了您建议的代码片段,但它不起作用(甚至不会更改输入框的内容)。我不太了解您的用例,但我使用了类似的方法:
$scope.get\u editor\u scope=function(){var forms=jQuery('form');var form=forms[forms.length-1];返回angular.element(form.scope();}$scope.item={}与使用函数
$scope.set_item=function(object){$scope.item=object;}
http://localhost:8000/test/e2e/scenarios.js:17:4
Selector [ng\:model="data[1][1]"] did not match any elements.
element("#data1_1").query(function(el, done) {
      el.click();
      el.val(20);
      done();
  });