MCPcopy
hub / github.com/codeceptjs/CodeceptJS / switchToNextTab

Method switchToNextTab

lib/helper/Playwright.js:1855–1871  ·  view source on GitHub ↗

* Switch focus to a particular tab by its number. It waits tabs loading and then switch tab * * ```js * I.switchToNextTab(); * I.switchToNextTab(2); * ``` * * @param {number} [num=1]

(num = 1)

Source from the content-addressed store, hash-verified

1853 * @param {number} [num=1]
1854 */
1855 async switchToNextTab(num = 1) {
1856 if (this.isElectron) {
1857 throw new Error('Cannot switch tabs inside an Electron container')
1858 }
1859 const pages = await this.browserContext.pages()
1860
1861 const index = pages.indexOf(this.page)
1862 this.withinLocator = null
1863 const page = pages[index + num]
1864
1865 if (!page) {
1866 throw new Error(`There is no ability to switch to next tab with offset ${num}`)
1867 }
1868 await targetCreatedHandler.call(this, page)
1869 await this._setPage(page)
1870 return this._waitForAction()
1871 }
1872
1873 /**
1874 * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab

Callers

nothing calls this directly

Calls 2

_setPageMethod · 0.95
_waitForActionMethod · 0.95

Tested by

no test coverage detected