如果要在执行操作之前等待元素,则应使用:
http://www.protractortest.org/#/api?view=ProtractorExpectedConditions.prototype.visibilityOf
element.all(by.css('span.mat-option-text')).getText().then((values) => {
element.all(by.css('span.mat-option-text')).filter((elem, index) => {
return elem.getText().then((text) => {
return values[1] === text;
});
}).first().click();
});
现在你正在努力表演
getText()
在
ElementArrayFinder
ElementFinder
此外,你正在循环这些
两次。
在
filter()
你真是太棒了
index
但不要在任何地方使用它。索引是可选参数-如果您不打算使用它-ommit。
values[1] === text;
-如果你想选择
option2
describe('workspace-project App', () => {
it('should select', () => {
return browser.get('http://localhost:4200/test').then(() => {
return element(by.tagName('mat-form-field')).click().then(() => {
//add Expected Condition here
return element(by.css('mat-option[value="option2"]')).click();
});
});
});
});