switchWindow
Passa il focus a una particolare scheda / finestra.
Utilizzo
browser.switchWindow(matcher)
Parametri
Nome | Tipo | Dettagli |
---|---|---|
matcher | String, RegExp | Stringa o espressione regolare che corrisponde al titolo della pagina o all'URL, al nome della finestra, o all'handle della finestra |
Esempio
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)
});