跳至主要內容

switchWindow

將焦點切換到特定的標籤頁/視窗。

用法
browser.switchWindow(matcher)
參數
名稱類型詳細資訊
matcher字串RegExp符合頁面標題和網址或視窗名稱的字串或正規表示式
範例
switchWindow.js
it('should switch to another window', async () => {
// open url
await browser.url('https://google.com')

// create new window
await browser.newWindow('https://webdriverio.dev.org.tw')

// 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')
});

歡迎!我能幫你什麼嗎?

WebdriverIO AI Copilot