![](/img/trans.png)
[英]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.