switchWindow
Wechselt den Fokus zu einem bestimmten Tab / Fenster.
Verwendung
browser.switchWindow(matcher)
Parameter
Name | Typ | Details |
---|---|---|
matcher | String, RegExp | String oder regulärer Ausdruck, der entweder dem Seitentitel oder der URL, dem Fensternamen oder dem Fensterhandle entspricht |
Beispiel
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)
});