メインコンテンツにスキップ

ウィンドウの切り替え

特定のタブ/ウィンドウにフォーカスを切り替えます。

使用法
browser.switchWindow(matcher)
パラメータ
名前詳細
matcherString, RegExpページタイトルまたはURL、ウィンドウ名、またはウィンドウハンドルに一致する文字列または正規表現
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)
});

Welcome! How can I help?

WebdriverIO AI Copilot