我想在我的框架中实现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
,两者均无法正常工作。
答案 0 :(得分:0)
您是否尝试过将定位符定义从函数更改为变量?
同样,您也不必在预期条件行中使用await两次。
请尝试以下操作:
页面对象
// You should specify the index if using .all (with .get(index); at the end)
this.optyList = element.all(by.xpath("//a/ancestor::th[@scope='row']"));
规范(在这里您可以尝试使用visibilityOf
或presenceOf
)
this.Then(/^Select Any Opty and click on New button$/,async ()=>{
await cmBrowser.wait(EC.presenceOf(loginPO.optyList),20000);
// or:
await cmBrowser.wait(EC.visibilityOf(loginPO.optyList),20000);
});
答案 1 :(得分:0)
visibilityOf()
接受ElementFinder
,而不是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();
});