[英]How to validate all column headers of Angular Grid in Protractor test if headers span past the width of the screen?
[英]How to verify text within first column of Angular Grid in Protractor test?
作为对我的 Angular 应用程序进行 Protractor 测试的一部分,我正在尝试验证Angular 网格第一列中单元格内的文本。
下面的代码验证网格的每个单元格的文本:
element.all(by.css('div.ag-cell'))
.map(function (cell) {
return cell.getText();
})
.then(function (cellValues) {
expect(cellValues).toEqual(["Toyota", "Ford", "Porsche"]);
});
当针对下表运行时,此代码将检查“Toyota”、“Celica”、“35000”、“Ford”、“Mondeo”等(即每个单元格)
但是,我希望测试仅验证“Toyota”、“Ford”和“Porsche” (即此Angular Grid的第一列) :
有人可以告诉我为此我需要做些什么改变吗?
注意:如果aria-colindex="1"
left: 0px;"
可以用作选择器,那么我想我可以使用它。
我会使用col-id
而不是aria-colindex
,对你来说,我会假设col-id
会被make
,但我会首先向你展示使用aria-colindex
。
element.all(by.css('div.ag-cell[aria-colindex="1"]'))
.map(function (cell) {
return cell.getText();
})
.then(function (cellValues) {
expect(cellValues).toEqual(["Toyota", "Ford", "Porsche"]);
});
使用col-id
element.all(by.css('div.ag-cell[col-id="make"]'))
.map(function (cell) {
return cell.getText();
})
.then(function (cellValues) {
expect(cellValues).toEqual(["Toyota", "Ford", "Porsche"]);
});
查看 CSS 属性选择器: https://www.w3schools.com/css/css_attribute_selectors.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.