Skip to main content

browsingContexts

Get every open tab and window of the session as a browsing context, in the order the browser reports them. This includes tabs the page opened itself, e.g. through target="_blank" or window.open(). Frames are not in this list, get them with frame() on their tab.

Only available in a WebDriver BiDi session.

Usage​

await browser.browsingContexts()

Example​

browsingContexts.js
it('finds a tab the page opened', async () => {
const page = await browser.url('https://the-internet.herokuapp.com/windows')
await page.$('a[href="/windows/new"]').click()

const tab = await browser.waitUntil(async () => (
(await browser.browsingContexts()).find((context) => context.url.endsWith('/windows/new'))
))
console.log(await tab.$('h3').getText()) // outputs: "New Window"
})

Returns​

  • <BrowsingContext[]> return: the open tabs and windows

Welcome! How can I help?

WebdriverIO AI Copilot