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

Method switchToPreviousTab

lib/helper/Puppeteer.js:1122–1134  ·  view source on GitHub ↗

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

(num = 1)

Source from the content-addressed store, hash-verified

1120 * @param {number} [num=1]
1121 */
1122 async switchToPreviousTab(num = 1) {
1123 const pages = await this.browser.pages()
1124 const index = pages.indexOf(this.page)
1125 this.withinLocator = null
1126 const page = pages[index - num]
1127
1128 if (!page) {
1129 throw new Error(`There is no ability to switch to previous tab with offset ${num}`)
1130 }
1131
1132 await this._setPage(page)
1133 return this._waitForAction()
1134 }
1135
1136 /**
1137 * Close current tab and switches to previous.

Calls 2

_setPageMethod · 0.95
_waitForActionMethod · 0.95

Tested by

no test coverage detected