t.switchToPreviousWindow Method

Activates the previously active window. Can be chained with other TestController methods.

t.switchToPreviousWindow()  → this | Promise<any>

If no new windows are open or closed, consecutive method calls cycle between the two most recent windows.



test('Switch to the previous window', async t => {
    await t

    const url = await t.eval(() => document.documentURI);

    await t.expect(url).eql('https://testcafe.io/');