switchWindow
Alterna o foco para uma aba / janela específica.
Uso
browser.switchWindow(matcher)
Parâmetros
Nome | Tipo | Detalhes |
---|---|---|
matcher | String, RegExp | String ou expressão regular que corresponde ao título da página ou URL, ao nome da janela ou ao identificador da janela |
Exemplo
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)
});