【发布时间】:2018-10-12 21:13:11
【问题描述】:
想知道我是否可以得到一些帮助。当我声明这个 webelement 引用时,我返回了一个 <tr> 元素数组
locationAuditsBySourceListViewTableRows : { //returns an array
get : function(){
return this.locationAuditsBySourceListViewTable.all(by.repeater('audit in location.displayedProfileAudits'));
}
},
在其中一个<tr> 元素中是一个跨度,其中包含指定我要选择的行的文本。
我正在使用的当前框架有一些类似的方法,我试图为我的目的对其进行重构,但是这段代码失败了:
locationAuditsListViewRowBySource : {
value : function(sourceName){
return this.locationAuditsBySourceListViewTableRows.filter(elem => {
//elem - placeholder as we iterate through each element within the locationAuditsBySourceListViewTableRows array
return elem.element(by.css(".source-name.ng-binding")).getText().then((val) => {
return val.toLowerCase() == sourceName.toLowerCase();
});
}).first();
}
},
我的感觉是我尝试在表格行中引用跨度的方式不正确(调用是在 .filter() 方法中进行的):
return elem.element(by.css(".source-name.ng-binding")).getText().then((val) => {
这是步骤定义本身:
Then(/^I should see that location audit for source row: "([^"]*)" has a label for the source$/, function (sourceName, callback) {
browser.wait(EC.visibilityOf(listingsPageObj.locationAuditsBySourceListViewContainer), timeouts.EC_TIMEOUT).then(() => {
browser.wait(EC.visibilityOf(listingsPageObj.locationAuditsBySourceListViewTable), timeouts.EC_TIMEOUT).then(() => {
browser.wait(() => {
return listingsPageObj.locationAuditsBySourceListViewTableHeaders.count().then(cnt => (cnt > 0)); //which means that there are audit results displayed
}).then(() => {
//find a row in the list of displayed audits
var tableRow = listingsPageObj.locationAuditsListViewRowBySource(sourceName);
});
});
});
});
任何人都可以帮助我/引导我朝着正确的方向前进吗?
谢谢。
【问题讨论】:
标签: angularjs protractor automated-tests ui-automation qa