Grid 如何在量角器中验证网格表值?

Grid 如何在量角器中验证网格表值?,grid,protractor,Grid,Protractor,在“量角器”中,我想验证附加值是否显示在网格中。 如何验证它 网格如下所示: 在你这边试试,让我知道它是有效的: var a = element(by.xpath("//div[contains(text(), 'test_protractor')]")).getText().then(function(msg){ console.log(msg) expect(msg).toEqual("test_protractor") }) 如果有多个,并且您只想获取第一行,那么 假设您已创建

在“量角器”中,我想验证附加值是否显示在网格中。 如何验证它

网格如下所示:


在你这边试试,让我知道它是有效的:

var a  = element(by.xpath("//div[contains(text(), 'test_protractor')]")).getText().then(function(msg){
  console.log(msg)
  expect(msg).toEqual("test_protractor")
})
如果有多个,并且您只想获取第一行,那么


假设您已创建了一个包含以下详细信息的新行

var newRow = {
  "obligation_name" : "sudharsan",
  "status" : "",
  "module" : "Test Module"
}
如果要验证是否显示新输入的行,可以尝试以下代码

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);

提供html代码谢谢@kishanpatel..它非常大。。请看这里的代码片段…我正在考虑使用ng repeat,但不太确定如何使用相同的。。只需为网格提供html。好的..网格html在这里-你能为我提供网站链接吗?你的设想是什么?在网格中添加一个值,然后验证是否添加了值?例如,网格有5个不同的行条目,我想设置一个for循环。是否可能?是的,只需创建一个循环,而不是get(1)使用get(i)选择一个您认为是问题最佳解决方案的答案。要将答案标记为已接受,请单击答案旁边的复选标记,将其从灰显切换为已填写。你可以随时更改被接受的答案,或者干脆取消接受答案。欢迎:-)@kavif你有时间请看一看-我真的被这个问题困扰了一个多星期了Hanks sudharshan。我将尝试让您知道Sudharsan,即使该值被添加到网格中,错误仍在发生。-错误为,应为0大于0@kavitha,0不大于0,因为expectedRow.count()为0
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);