I need to locate and test a specific cell in an ng-grid table to ensure it's not showing 'NaN'. I have been able to locate cells in columns 1-7, but this cell is in column 14, which a user needs to scroll horizontally to see. When trying to locate cells 8-14, protractor just returns undefined. I've tried resizing the window before the test, to no avail.
我需要定位并测试一个ng-grid表中的特定单元格,以确保它不显示“NaN”。我可以在列1-7中找到单元格,但是这个单元格在列14中,用户需要水平滚动才能看到。当尝试定位单元格8-14时,量角器只返回未定义的值。我试过在测试前调整窗口的大小,但没有效果。
Code:
代码:
it('should have values in the adverse events tab for the Fosamax column when viewing Postmenopausal Osteoporosis report', function () {
browser.get('/#/druggroup/indication/N0000003303/adverseevents/IR');
var fosamaxCell = element.all(by.repeater('row in renderedRows')).then(function(rows) {
cell = rows[6].element(by.className('colt14')).getText()
.then(function (data) {
return data.replace(/ /g,'');
});
return cell;
});
expect(fosamaxCell).toEqual('NaN');
});
1 个解决方案
#1
2
Scrolling into view should help here:
滚动到视图应该在这里有所帮助:
var elm = rows[6].element(by.className('colt14'));
browser.executeScript("arguments[0].scrollIntoView(true);", elm.getWebElement());
cell = elm.getText().then(function (data) {
return data.replace(/ /g,'');
});
#1
2
Scrolling into view should help here:
滚动到视图应该在这里有所帮助:
var elm = rows[6].element(by.className('colt14'));
browser.executeScript("arguments[0].scrollIntoView(true);", elm.getWebElement());
cell = elm.getText().then(function (data) {
return data.replace(/ /g,'');
});