Testafe:如何在多个窗口之间切换 [英] Testcafe: how to Switch Between multiple windows

查看:0
本文介绍了Testafe:如何在多个窗口之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为多个窗口编写了代码。也就是说,当我点击按钮时,它将打开新窗口,然后在该窗口中,我必须进行点击操作。 我用过这个代码 Const y=等待客户端函数(()=>;window.location.pathname)()

   await t.switchToWindow(f => f.url.pathname === y)

enter image description here

enter image description here

推荐答案

总的来说,您的方法是正确的。 请看此示例:

fixture `fixture`
    .page `http://example.com`;

test(`test`, async t => {
    await t.openWindow('http://google.com');

    await t.switchToWindow(data => {
        return data.url.hostname === 'example.com';
    });

    await t.click('h1');
});

如果没有帮助,请共享演示此问题的示例。

这篇关于Testafe:如何在多个窗口之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆