In protractor, I want to verify whether added value is displaying in the grid. How do I validate it?
The grid looks like this:
In protractor, I want to verify whether added value is displaying in the grid. How do I validate it?
The grid looks like this:
Try it at your end and let me know it works:
var a = element(by.xpath("//div[contains(text(), 'test_protractor')]")).getText().then(function(msg){
console.log(msg)
expect(msg).toEqual("test_protractor")
})
If there are multiple and you want to get only first row then
var a = element.all(by.xpath("//div[contains(text(), 'test_protractor')]")).get(1).getText().then(function(msg){
console.log(msg)
expect(msg).toEqual("test_protractor")
})
Let me assume you have created a new row with below details,
var newRow = {
"obligation_name" : "sudharsan",
"status" : "",
"module" : "Test Module"
}
If you want to verify that the newly entered row is displayed,You can try the below code,
var rowList = element.all(by.repeater("(colRenderIndex, col) in colContainer.renderedColumns"));
var expectedRow = rowList.filter(function(rowElement,index) {
var columnList = rowElement.all(by.css("div.ui-grid-cell-contents"));
return columnList.getText().then(function(columnValues) {
return (columnValues[0]== newRow["obligation_name"]) && (columnValues[1] == newRow["status"]) && (columnValues[2] == newRow["module"]);
});
});
expect(expectedRow.count()).toBeGreaterThan(0);