![](/img/trans.png)
[英]Can i run protractor e2e sanity testsuit from the UI by clicking html button
[英]how can I read dynamic value in ui in e2e protractor
我正在量角器中开发e2e测试。 我正在运行测试Chrome浏览器。 在用户界面中有一个动态字段:
<div ng-show="searchResult.count" >
<h4>Search Results: </h4>
<p id="font-weight-500">{{searchResult.count}} Items</p>
<hr>
</div>
我需要取searchResult.count的值
我试过了
element(by.binding('searchResult.count'));
$('[ng-show="searchResult.count"]')
;
我在html中做了一些更改,并在div中添加了ng-model ='shearchResult.count'
<div ng-show="searchResult.count" ng-model="searchResult.count">
然后我打电话
element(by.model("searchResult.count"));
他们所有的结果都是一样的:
<h4>Search Results: </h4>
<p id="font-weight-500" class="ng-binding"> Items</p>
<hr>
我也尝试使用$ scope
SearchPage.prototype.getSearchResultNumber=function($scope){
....
var value=$scope.searchResult.count;
....
但是我得到了“ $ scope”是不确定的结果,尽管我可以在Web浏览器中看到该数字,但我无法读取或接受量角器中的e2e规范。
如何获得动态生成的数据? 谁能帮我解决这个问题? 谢谢
您可以使用getAttribute()
获得ng-model
属性的值来解决此问题:
var div = element(by.model("searchResult.count"));
expect(div.getAttribute('ng-model')).toBe('10'); // 10 is an example
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.