* 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)
| 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. |
no test coverage detected