【发布时间】:2015-09-15 11:45:28
【问题描述】:
我正在学习量角器,并试图在 angularjs.org 页面的输入字段中发送密钥,但我收到此错误:
NoSuchElementError:使用定位器找不到元素: By.model("projectList.search")
这是我的代码:
describe ("Search list", function() {
it ("should search for jQuery and display 1 result", function() {
browser.get("https://angularjs.org/");
element(by.model("projectList.search")).sendKeys("jQuery");
});
});
我尝试使用 by.id 并得到同样的错误。我假设这是因为元素还不可见。当我添加 browser.pause() 并逐步(慢慢地)进行时,测试通过了。解决这个问题的最佳方法是什么?
来自 angularjs.org 的相关 HTML
<input type="text" ng-model="projectList.search" class="search-query" id="projects_search"
placeholder="Search">
<table>
<thead>
<tr>
<th>Project</th>
<th>Description</th>
<th><a href="#/new"><i class="icon-plus-sign"></i></a></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="project in projectList.projects | filter:projectList.search | orderBy:'name'">
<td><a ng-href="{{project.site}}" target="_blank">{{project.name}}</a></td>
<td>{{project.description}}</td>
<td>
<a ng-href="#/edit/{{project.$id}}"><i class="icon-pencil"></i></a>
</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
能否提供相关的html代码
标签: angularjs protractor