在网格中查找带有页面的元素,然后使用量角器单击它

时间:2017-08-09 19:00:25

标签: javascript protractor

我有一个启用了分页的网格,我需要浏览页面以找到所需的行并使用量角器单击它。我可以点击第一页中的特定行,但如果它不在第一页上,那么我需要点击下一页并检查所需的行。

element.all("by.id('value').filter((row) => {
  return row.getText().then((text) => {
    if (text.indexOf(text) != -1) {
      return true;
    }
  });
}).then((rows) => {
  if (rows)
    rows[0].element(by.name('name')).click();
});

即使在第一页上找到该元素,代码也会运行5次

for(i=0;i<5;i++) {
  ( (i) =>{
    console.log('I:'+i);
    element.all("by.id('value').filter((row) => {
      return row.getText().then((text) => {
        if (text.indexOf(someval) != -1) {
          return true;
        }
      });
    }).then((rows) => {  
        if(matchingRows.length>0){
     matchingRows[0].element(by.css(this.button)).click();
        return;
      }
    });
  })(i);
next.click();
 }
}

0 个答案:

没有答案
相关问题