如何解决检查链接后如何等待页面转换?
我试图让 CodeceptJS 在单击链接后等待页面加载,但我无法让它优雅地这样做。
我的 Ionic 页面:
主页
<IonPage>
<IonHeader>
<IonToolbar>
<IonButtons slot="start">
<IonBackButton />
</IonButtons>
<IonTitle>Main page</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent>
<Link to="reset-password">Reset Password</Link>
</IonContent>
</IonPage>
重置密码页面
<IonPage>
<IonHeader>
<IonToolbar>
<IonButtons slot="start">
<IonBackButton />
</IonButtons>
<IonTitle>Reset your password</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent>
Here is a form.
</IonContent>
</IonPage>
我的 codeceptJS 测试(使用 Playwright):
Scenario('Reset password',async ({ I }) => {
I.amOnPage('/');
I.wait('ion-button');
I.click('Reset Password');
// Wait for URL to change; doesn't help.
I.waitInUrl('/reset-path')
// Wait for "Reset Password" link to disappear; doesn't help.
I.waitForInvisible('Reset Password');
// Wait for new title text to appear; doesn't help.
I.waitForText('Reset your password');
// Simply wait 1 second; this is the only way to make sure the page is loaded.
I.wait(1);
const titleText = await I.grabTextFrom('ion-toolbar ion-title');
assert.strictEqual('Reset your password',titleText);
});
如果我不等待 1 秒,则会出现以下错误:
Expected values to be strictly equal:
+ actual - expected
+ 'Reset your password'
- 'Main page'
因此,即使我告诉 CodeceptJS 等到新的标题文本可见,它还是会以某种方式看到旧的标题文本,除非我硬编码等待时间。当然我做错了(今天刚开始使用 CodeceptJS),并且有一种方法可以优雅地强制它等待 Ionic 页面转换发生。我该怎么做?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。