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

Method _startBrowser

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

Source from the content-addressed store, hash-verified

633 }
634
635 async _startBrowser() {
636 try {
637 if (this.options.multiremote) {
638 this.browser = await webdriverio.multiremote(this.options.multiremote)
639 } else {
640 // remove non w3c capabilities
641 delete this.options.capabilities.protocol
642 delete this.options.capabilities.hostname
643 delete this.options.capabilities.port
644 delete this.options.capabilities.path
645 this.browser = await webdriverio.remote(this.options)
646 }
647 } catch (err) {
648 if (err.toString().indexOf('ECONNREFUSED')) {
649 throw new ConnectionRefused(err)
650 }
651 throw err
652 }
653
654 this.isRunning = true
655 if (this.options.timeouts && this.isWeb) {
656 await this.defineTimeout(this.options.timeouts)
657 }
658
659 await this._resizeWindowIfNeeded(this.browser, this.options.windowSize)
660
661 this.$$ = this.browser.$$.bind(this.browser)
662
663 if (this._isCustomLocatorStrategyDefined()) {
664 Object.keys(this.customLocatorStrategies).forEach(async customLocator => {
665 this.debugSection('Weddriver', `adding custom locator strategy: ${customLocator}`)
666 const locatorFunction = this._lookupCustomLocator(customLocator)
667 this.browser.addLocatorStrategy(customLocator, locatorFunction)
668 })
669 }
670
671 if (this.browser.capabilities && this.browser.capabilities.platformName) {
672 this.browser.capabilities.platformName = this.browser.capabilities.platformName.toLowerCase()
673 }
674
675 this.browser.on('dialog', () => {})
676
677 // Check for Bidi, because "sessionSubscribe" is an exclusive Bidi protocol feature. Otherwise, error will be thrown.
678 if (this.browser.capabilities && this.browser.capabilities.webSocketUrl) {
679 await this.browser.sessionSubscribe({ events: ['log.entryAdded'] })
680 this.browser.on('log.entryAdded', logEvents)
681 }
682
683 return this.browser
684 }
685
686 _isCustomLocatorStrategyDefined() {
687 return this.customLocatorStrategies && Object.keys(this.customLocatorStrategies).length

Callers 2

_beforeSuiteMethod · 0.95
_beforeMethod · 0.95

Calls 5

defineTimeoutMethod · 0.95
_resizeWindowIfNeededMethod · 0.95
_lookupCustomLocatorMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected