the scope can be changed
. 你可以用
arrow function
为了访问正确的范围:
await browser.wait(
async () => (await this.getProjectNameBreadCrumbText()).includes(projectName),
this.DEFAULT_WAIT_TIME_SECONDS * 1000,
'Name Breadcrumb for this page never loaded.'
);
作为其他选择-你可以
bind
手动将函数添加到所需范围:
this.getProjectNameBreadCrumbText = this.getProjectNameBreadCrumbText.bind(this);
await browser.wait(
async function() {return (await this.getProjectNameBreadCrumbText()).indexOf(projectName) > -1;},
this.DEFAULT_WAIT_TIME_SECONDS * 1000,
'Name Breadcrumb for this page never loaded.')