* {{> switchToPreviousTab }}
(num = 1, sec = null)
| 2816 | * {{> switchToPreviousTab }} |
| 2817 | */ |
| 2818 | async switchToPreviousTab(num = 1, sec = null) { |
| 2819 | const aSec = sec || this.options.waitForTimeoutInSeconds |
| 2820 | const current = await this.browser.getWindowHandle() |
| 2821 | let target |
| 2822 | |
| 2823 | await this.browser.waitUntil( |
| 2824 | async () => { |
| 2825 | await this.browser.getWindowHandles().then(handles => { |
| 2826 | if (handles.indexOf(current) - num > -1) { |
| 2827 | target = handles[handles.indexOf(current) - num] |
| 2828 | } |
| 2829 | }) |
| 2830 | return target |
| 2831 | }, |
| 2832 | { timeout: aSec * 1000, timeoutMsg: `There is no ability to switch to previous tab with offset ${num}` }, |
| 2833 | ) |
| 2834 | return this.browser.switchToWindow(target) |
| 2835 | } |
| 2836 | |
| 2837 | /** |
| 2838 | * {{> closeCurrentTab }} |
nothing calls this directly
no test coverage detected