我學習量角器,我試圖在的SendKeys在angularjs.org頁面輸入字段,但我收到此錯誤:量角器的SendKeys返回NoSuchElementError
NoSuchElementError: No element found using locator: 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
<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代碼 –