问题描述
我正在尝试将页面结果存储到变量中,因此我可以使用它来访问其他页面,但是遇到错误“ TypeError:无法读取未定义的属性'waitForSelector'”
export default class ParentChecker {
constructor() {
this.data = {
'foo': 'bar',};
}
handleNameBlur(e) {
console.log(this.data); // <=== "this" result to undefined.
/* ... */
}
}
解决方法
page.click
将不会返回页面。您可以在那里使用waitForNavigation
。
await Promise.all([
page.waitForNavigation(),page.click('button[type="submit"]')]);