Not able to select an element using protractor vir

2019-03-01 20:42发布

问题:

I was able to select an element using ng-repeat but the developers have used virtual repeat as such the following code does not work now

expect(stores.listStores(0).getText()).toContain('Prahran');
expect(element.all(by.repeater('store in ui.stores')).count()).toEqual(1);

Failed: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator by.repeater("store in ui.stores")

回答1:

You can make a CSS selector to match the material design repeater elements:

element.all(by.css('[md-virtual-repeat="store in ui.stores"]'));