首页 > 解决方案 > ExpectedConditions 在量角器中抛出错误

问题描述

我想在我的框架中实现 ExpectedConditions 但它抛出了一些我无法理解的错误。有人可以帮助我吗?

步骤定义

this.Then(/^Select Any Opty and click on New button$/, async () => {
    cmBrowser.sleep(10000);
    await cmBrowser.wait(EC.visibilityOf(await loginPO.optyList()),20000);
    var list=await loginPO.optyList();
});

页面对象

this.optyList = function () {
    // return $$("table[role='grid'] th span a");
    return element.all(by.xpath("//a/ancestor::th[@scope='row']"));
}

错误日志

 TypeError: Cannot read property 'bind' of undefined
    at ProtractorExpectedConditions.presenceOf (C:\Users\srongala\AppData\Roaming\npm\node_modules\protractor\built\expectedConditions.js:341:40)
    at ProtractorExpectedConditions.visibilityOf (C:\Users\srongala\AppData\Roaming\npm\node_modules\protractor\built\expectedConditions.js:381:30)
    at World.(anonymous) (C:\Users\srongala\Documents\My Received Files\Automation\Proc\Test_modules\step_definitions\PGS_ES.js:47:39)
    at runMicrotasks ((anonymous))
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

我正在使用的应用程序是非角度应用程序..我查看了其他问题中提供的解决方案,他们说需要使用browser.ignoreSynchronization=true,但我尝试了两者browser.waitForAngularEnabled();,并且browser.ignoreSynchronization=true两者都不起作用。

标签: javascriptselenium-webdriverprotractorcucumberjs

解决方案


visibilityOf()accept ElementFinder, not ElmentFinderArray,你不应该传入元素数组。

this.Then(/^Select Any Opty and click on New button$/, async () => {
    cmBrowser.sleep(10000);
    await cmBrowser.wait(EC.visibilityOf(await loginPO.optyList().first()),20000);
    var list=await loginPO.optyList();
});

推荐阅读