简体   繁体   中英

Using Protractor with Angular2

I have a little project in angular2 that I'm trying to write some simple tests for using protractor..

I am using a ngFor to loop round a list of 'foos' and display them on the page (simple enough).

Then I want my test to get the text of the 1st one and check to see if it's '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

Any idea what I doing wrong?

The problem is that:

Instead, do:

var elm = element.all(by.repeater('foo of foos')).get(1);
expect(elm.getText()).toEqual('bar');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM