* {{> switchToNextTab }}
(num = 1, sec = null)
| 2794 | * {{> switchToNextTab }} |
| 2795 | */ |
| 2796 | async switchToNextTab(num = 1, sec = null) { |
| 2797 | const aSec = sec || this.options.waitForTimeoutInSeconds |
| 2798 | let target |
| 2799 | const current = await this.browser.getWindowHandle() |
| 2800 | |
| 2801 | await this.browser.waitUntil( |
| 2802 | async () => { |
| 2803 | await this.browser.getWindowHandles().then(handles => { |
| 2804 | if (handles.indexOf(current) + num + 1 <= handles.length) { |
| 2805 | target = handles[handles.indexOf(current) + num] |
| 2806 | } |
| 2807 | }) |
| 2808 | return target |
| 2809 | }, |
| 2810 | { timeout: aSec * 1000, timeoutMsg: `There is no ability to switch to next tab with offset ${num}` }, |
| 2811 | ) |
| 2812 | return this.browser.switchToWindow(target) |
| 2813 | } |
| 2814 | |
| 2815 | /** |
| 2816 | * {{> switchToPreviousTab }} |
nothing calls this directly
no test coverage detected