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

Method _startBrowser

lib/helper/Appium.js:317–373  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

315 }
316
317 async _startBrowser() {
318 if (this.appiumV2 === true) {
319 this.options.capabilities = this._convertAppiumV2Caps(this.options.capabilities)
320 this.options.desiredCapabilities = this._convertAppiumV2Caps(this.options.desiredCapabilities)
321 }
322
323 try {
324 if (this.options.multiremote) {
325 this.browser = await webdriverio.multiremote(this.options.multiremote)
326 } else {
327 this.browser = await webdriverio.remote(this.options)
328 }
329 } catch (err) {
330 if (err.toString().indexOf('ECONNREFUSED')) {
331 throw new ConnectionRefused(err)
332 }
333 throw err
334 }
335 this.$$ = this.browser.$$.bind(this.browser)
336
337 // wdio v9 implements `element.isDisplayed()` for non-mobile contexts by
338 // injecting a JS visibility check via POST /execute/sync. Appium's native
339 // context cannot execute JS, so each call logs an ugly
340 // "Method is not implemented" ERROR before the existing catch swallows it.
341 // Short-circuit isDisplayed to `true` while in native context so the
342 // request is never issued (matches existing _isDisplayedSafe semantics).
343 const helper = this
344 if (typeof this.browser.overwriteCommand === 'function') {
345 this.browser.overwriteCommand(
346 'isDisplayed',
347 async function (origFn, ...args) {
348 if (helper.isWeb) return origFn.call(this, ...args)
349 return true
350 },
351 true,
352 )
353 }
354
355 this.isRunning = true
356 if (this.options.timeouts && this.isWeb) {
357 await this.defineTimeout(this.options.timeouts)
358 }
359 if (this.options.windowSize === 'maximize' && !this.platform) {
360 const res = await this.browser.execute('return [screen.width, screen.height]')
361 return this.browser.windowHandleSize({
362 width: res.value[0],
363 height: res.value[1],
364 })
365 }
366 if (this.options.windowSize && this.options.windowSize.indexOf('x') > 0 && !this.platform) {
367 const dimensions = this.options.windowSize.split('x')
368 await this.browser.windowHandleSize({
369 width: dimensions[0],
370 height: dimensions[1],
371 })
372 }
373 }
374

Callers 2

Playwright_test.jsFile · 0.45
Puppeteer_test.jsFile · 0.45

Calls 3

_convertAppiumV2CapsMethod · 0.95
defineTimeoutMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected