"is not a function" 从 WebdriverIO 中的基本页面对象页面调用方法时出错
"is not a function" error when calling a method from basic pageobject page in WebdriverIO
我一直在使用页面 object 模式和 WebdriverIO,并尝试声明一个将在 child 页面中继承的选择器。这两个我都试过了
function Page() {
this.loader = function() {
return $("div[class*='loading'] svg");
}
}
还有这个
Page.prototype.loader = function() {
return $("div[class*='loading'] svg");
}
当我从 child 页调用此函数时,例如
checkoutPage.loader.waitForVisible(5000, true);
我收到 "checkoutPage.loader.waitForVisible" 不是函数”错误。我如何为基本页面声明 getter 以便可以从任何 child 调用它?
当您调用 checkoutPage.loader.waitForVisible(5000, true)
时,您实际上返回的是整个 loader
函数而不是元素。
将其更改为 checkoutPage.loader().waitForVisible(5000, true);
,您的第一个示例应该可以正常工作。
我一直在使用页面 object 模式和 WebdriverIO,并尝试声明一个将在 child 页面中继承的选择器。这两个我都试过了
function Page() {
this.loader = function() {
return $("div[class*='loading'] svg");
}
}
还有这个
Page.prototype.loader = function() {
return $("div[class*='loading'] svg");
}
当我从 child 页调用此函数时,例如
checkoutPage.loader.waitForVisible(5000, true);
我收到 "checkoutPage.loader.waitForVisible" 不是函数”错误。我如何为基本页面声明 getter 以便可以从任何 child 调用它?
当您调用 checkoutPage.loader.waitForVisible(5000, true)
时,您实际上返回的是整个 loader
函数而不是元素。
将其更改为 checkoutPage.loader().waitForVisible(5000, true);
,您的第一个示例应该可以正常工作。