Saikrishna
Saikrishna

Reputation: 1

Testcafe: how to Switch Between multiple windows

i have write code for multiple windows. i.e when i click on button it will open new window then in that window i have to do click operation . i have used this code const y=await ClientFunction(() => window.location.pathname)()

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

enter image description here

enter image description here

Upvotes: 0

Views: 571

Answers (1)

Alex Kamaev
Alex Kamaev

Reputation: 6318

In general, your approach is correct. Take a look at this sample:

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

If it does not help, please share a sample that demonstrates the issue.

Upvotes: 1

Related Questions