MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / switchToNextTab

Method switchToNextTab

lib/helper/WebDriver.js:2796–2813  ·  view source on GitHub ↗

* {{> switchToNextTab }}

(num = 1, sec = null)

Source from the content-addressed store, hash-verified

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 }}

Callers

nothing calls this directly

Calls 1

switchToWindowMethod · 0.80

Tested by

no test coverage detected