webdriverio
Version:
Next-gen browser and mobile automation test framework for Node.js
41 lines (40 loc) • 1.85 kB
TypeScript
import type { NewWindowOptions } from '../../types.js';
/**
*
* Open a new window or tab and wait until its page has loaded, the equivalent of `window.open()`.
* This command does not work in mobile environments.
*
* In a WebDriver BiDi session (the default since v10) it returns the new
* [browsing context](/docs/api/browsingContext) and does not switch to it: run
* commands on the returned context, while `browser.url()` keeps navigating the
* first one. In a WebDriver Classic session the command switches to the new window
* and returns `{ handle, type }`.
*
* <example>
:newWindow.js
it('should open a new tab', async () => {
const page = await browser.url('https://webdriver.io')
const tab = await browser.newWindow('https://webdriver.io/docs/api', { type: 'tab' })
console.log(await tab.getTitle()) // the title of the API page
console.log(await page.getTitle()) // the first tab still answers commands
await tab.closeWindow()
});
* </example>
*
* @param {string} url website URL to open
* @param {NewWindowOptions=} options newWindow command options
* @param {string=} options.type type of new window: 'tab' or 'window'
*
* @return {BrowsingContext|Object} In a BiDi session, the new browsing context. In a Classic session, `{handle, type}`.
*
* @throws {Error} If `url` is invalid, if the command is used on mobile, or `type` is not 'tab' or 'window'.
*
* @uses browser/execute, protocol/getWindowHandles, protocol/switchToWindow
* @alias browser.newWindow
* @type window or tab
*/
export declare function newWindow(this: WebdriverIO.Browser, url: string, options?: NewWindowOptions): Promise<WebdriverIO.BrowsingContext | {
handle: string;
type: 'tab' | 'window';
}>;
//# sourceMappingURL=newWindow.d.ts.map