MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / switchToNextTab

Method switchToNextTab

lib/helper/Puppeteer.js:1099–1111  ·  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

1097 * @param {number} [num=1]
1098 */
1099 async switchToNextTab(num = 1) {
1100 const pages = await this.browser.pages()
1101 const index = pages.indexOf(this.page)
1102 this.withinLocator = null
1103 const page = pages[index + num]
1104
1105 if (!page) {
1106 throw new Error(`There is no ability to switch to next tab with offset ${num}`)
1107 }
1108
1109 await this._setPage(page)
1110 return this._waitForAction()
1111 }
1112
1113 /**
1114 * Switch focus to a particular tab by its number. It waits tabs loading and then switch tab

Calls 2

_setPageMethod · 0.95
_waitForActionMethod · 0.95

Tested by

no test coverage detected