Protractor GragratorJS-如何使用它来查看web元素数组是否包含字符串?

Protractor GragratorJS-如何使用它来查看web元素数组是否包含字符串?,protractor,ui-automation,chai,qa,Protractor,Ui Automation,Chai,Qa,这是我正在创建的webelement get importErrorsList(){ return element.all(by.repeater('error in profiles.importErrors')); } 以下是我正在创建的引用webelement的步骤: Then(/^The list of import errors contains this error message: "([^"]*)"$/, async (errorText)

这是我正在创建的webelement

get importErrorsList(){        
  return element.all(by.repeater('error in profiles.importErrors'));        
}
以下是我正在创建的引用webelement的步骤:

Then(/^The list of import errors contains this error message: "([^"]*)"$/, async (errorText) => {

  await browser.wait(EC.visibilityOf(importPageObj.alertMsg), timeouts.EC_TIMEOUT);
  var count = await directoriesPageObj.importErrorsList.count();
  console.log("outside if statement: ---------" + directoriesPageObj.importErrorsList);

    if (count > 0) {

      var errorListText=[];
      errorListText = await directoriesPageObj.importErrorsList.getText();
      //expect(await errorListText).to.eventually.contain(errorText);
      //this call ^^ will result in a "not a thenable" type of error
      //expect(await errorListText).to.contain(errorText);
      //this call ^^ will result in the value of "errorText" being compared to an array object
};
根据我在expect调用上所做的链接类型,我看到了不同类型的错误(每种类型的expect调用的错误类型都在代码中调用本身的旁边)


有人能给我解释一下为什么这不起作用吗?我猜这很简单,但我已经尝试了很多东西,几个小时来我一直在试图解决这个问题,但我仍然感到困惑。

从未使用过chai,但出现了一系列奇怪的错误,直到我切换到使用
async/wait
,然后您的代码变得非常明确和清晰。我建议您执行samei更新,将方法更新为异步,但我仍然看到@SergeyPleshakovthen@Lesstof的相同类型的错误,然后让我们看看您看到的错误。当前的是什么?根据我在expect调用中使用的链接类型,我会得到不同的错误。当我使用:
expect(wait bannersList).to.finally.contain(errorText)
//此调用^^^将导致“非可设置”类型的错误
expect(等待errorListText).to.contain(errorText)
//此调用^^将导致将“errorText”的值与数组对象进行比较
等待横幅列表
此表达式似乎不正确。什么是横幅列表?