我正在尝试使用 Selenium webdriver 和 Mocha 将我的测试重构为具有异步/等待功能的 ES7。我有以下代码:
await loginPage.loginAsAdmin()
/* THIS DOES NOT WORK */
//await layout.Elements.routePageButton().click()
/* THIS DOES WORK */
let a = await layout.Elements.routePageButton()
await a.click()
我不明白为什么这个特别不起作用 - 我得到:
TypeError: layout.Elements.routePageButton(...).click is not a function
click方法返回webElement之前的函数,可以看到:
布局:
routePageButton: async () => await findVisibleElement('#route_info a')
const findVisibleElement = utils.Methods.Element.findVisible
方法:
findVisible: async (cssSelector) => {
let elm = await driver().findElement(by.css(cssSelector))
return elm
}