我想在 getText() 函数之外保留变量,以便我可以将它与测试中的值匹配。例子:
页面对象文件:
this.numberOfAllLines = element(by.id('all_lines'));
this.tableCell = element(by.css('.table_results_lines'));
this.sumOfAllLinesText = element(by.id('sum_lines'));
规格文件:
var numberOfLines = '';
var newNumberOfLines = '';
describe(...
it(...
page.numberOfAllLines.getText().then(function(num) {
numberOfLines = num;
});
newNumberOfLines = numberOfLines + 10;
expect(page.tableCell.getText()).toEqual(newNumberOfLines);
// doing some clicks
expect(page.sumOfAllLinesText.getText()).toEqual(newNumberOfLines);
});
});