Hoppa till huvudinnehåll

switchWindow

Växla fokus till en specifik flik / fönster.

Användning
browser.switchWindow(matcher)
Parametrar
NamnTypDetaljer
matcherString, RegExpSträng eller reguljärt uttryck som matchar antingen sidtitel eller URL, fönsternamn eller fönsterhanterare
Exempel
switchWindow.js
it('should switch to another window', async () => {
// open url
await browser.url('https://google.com')

// get window handle
const handle = await browser.getWindowHandle()

// create new window
await browser.newWindow('https://webdriver.io')

// switch back via url match
await browser.switchWindow('google.com')

// switch back via title match
await browser.switchWindow('Next-gen browser and mobile automation test framework for Node.js')

// switch back via window handle
await browser.switchWindow(handle)
});

Welcome! How can I help?

WebdriverIO AI Copilot