Testafe:如何在多个窗口之间切换多个、窗口、如何在、Testafe

2023-09-03 11:35:12 作者:只想征服

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

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

enter image description here

excel2016多窗口显示

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');
});

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

 
精彩推荐