webdriverio
Version:
Next-gen browser and mobile automation test framework for Node.js
34 lines (33 loc) • 1.38 kB
TypeScript
/**
* Switch focus to a particular tab / window (Classic sessions).
*
* In a WebDriver BiDi session this command throws. `browser.url()` and
* `browser.newWindow()` return the browsing context, and `browser.browsingContexts()`
* lists the open top-level contexts. Commands run on the context you hold.
*
* <example>
:switchWindow.js
it('should switch to another window', async () => {
// Classic
await browser.url('https://google.com')
const handle = await browser.getWindowHandle()
await browser.newWindow('https://webdriver.io')
await browser.switchWindow('google.com')
await browser.switchWindow(handle)
// BiDi
const google = await browser.url('https://google.com')
const docs = await browser.newWindow('https://webdriver.io')
console.log(await docs.getTitle())
console.log(await google.getTitle())
});
* </example>
*
* @param {String|RegExp} matcher String or regular expression that matches either the page title or URL, the window name, or the window handle
*
* @uses protocol/getWindowHandles, protocol/switchToWindow, protocol/getUrl, protocol/getTitle
* @alias browser.switchTab
* @type window
*
*/
export declare function switchWindow(this: WebdriverIO.Browser, matcher: string | RegExp): Promise<string>;
//# sourceMappingURL=switchWindow.d.ts.map