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

Method switchToPreviousTab

lib/helper/WebDriver.js:2818–2835  ·  view source on GitHub ↗

* {{> switchToPreviousTab }}

(num = 1, sec = null)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

switchToWindowMethod · 0.80

Tested by

no test coverage detected