* 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)
| 1880 | * @param {number} [num=1] |
| 1881 | */ |
| 1882 | async switchToPreviousTab(num = 1) { |
| 1883 | if (this.isElectron) { |
| 1884 | throw new Error('Cannot switch tabs inside an Electron container') |
| 1885 | } |
| 1886 | const pages = await this.browserContext.pages() |
| 1887 | const index = pages.indexOf(this.page) |
| 1888 | this.withinLocator = null |
| 1889 | const page = pages[index - num] |
| 1890 | |
| 1891 | if (!page) { |
| 1892 | throw new Error(`There is no ability to switch to previous tab with offset ${num}`) |
| 1893 | } |
| 1894 | |
| 1895 | await this._setPage(page) |
| 1896 | return this._waitForAction() |
| 1897 | } |
| 1898 | |
| 1899 | /** |
| 1900 | * Close current tab and switches to previous. |
no test coverage detected