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

Method _session

lib/helper/WebDriver.js:731–766  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

729 }
730
731 _session() {
732 const defaultSession = this.browser
733 return {
734 start: async (sessionName, opts) => {
735 // opts.disableScreenshots = true; // screenshots cant be saved as session will be already closed
736 opts = this._validateConfig(Object.assign(this.options, opts))
737 this.debugSection('New Browser', JSON.stringify(opts))
738 const browser = await webdriverio.remote(opts)
739 this.activeSessionName = sessionName
740 if (opts.timeouts && this.isWeb) {
741 await this._defineBrowserTimeout(browser, opts.timeouts)
742 }
743
744 await this._resizeWindowIfNeeded(browser, opts.windowSize)
745
746 return browser
747 },
748 stop: async browser => {
749 if (!browser) return
750 return browser.deleteSession()
751 },
752 loadVars: async browser => {
753 if (this.context !== this.root) throw new Error("Can't start session inside within block")
754 this.browser = browser
755 this.$$ = this.browser.$$.bind(this.browser)
756 this.sessionWindows[this.activeSessionName] = browser
757 },
758 restoreVars: async session => {
759 if (!session) {
760 this.activeSessionName = ''
761 }
762 this.browser = defaultSession
763 this.$$ = this.browser.$$.bind(this.browser)
764 },
765 }
766 }
767
768 /**
769 * Use [webdriverio](https://webdriver.io/docs/api.html) API inside a test.

Callers

nothing calls this directly

Calls 3

_validateConfigMethod · 0.95
_defineBrowserTimeoutMethod · 0.95
_resizeWindowIfNeededMethod · 0.95

Tested by

no test coverage detected