[英]Using Protractor with Angular2
I have a little project in angular2 that I'm trying to write some simple tests for using protractor.. 我在angular2中有一个小项目,我试图编写一些使用量角器的简单测试。
I am using a ngFor to loop round a list of 'foos' and display them on the page (simple enough). 我正在使用ngFor循环遍历“ foos”列表,并将其显示在页面上(足够简单)。
Then I want my test to get the text of the 1st one and check to see if it's 'bar': 然后我要我的测试获取第一个文本,并检查它是否为“ bar”:
element.all(by.repeater('foo of foos')).get(1).then(function(x){
expect(x.getText()).toEqual('bar');
});
But when I run my test I get: 但是当我运行测试时,我得到:
Failed: element.all(...).get(...).then is not a function
失败:element.all(...)。get(...)。那么不是函数
Any idea what I doing wrong? 知道我做错了什么吗?
The problem is that: 问题是:
element.all(by.repeater('foo of foos')).get(1)
is an ElementFinder
element.all(by.repeater('foo of foos')).get(1)
是一个ElementFinder
ElementFinder
with then()
( breaking change in Protractor 2.0.0 ) then()
解决ElementFinder
( 打破Protractor 2.0.0中的更改 ) Instead, do: 相反,请执行以下操作:
var elm = element.all(by.repeater('foo of foos')).get(1);
expect(elm.getText()).toEqual('bar');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.