MCPcopy Create free account
hub / github.com/webdriverio/webdriverio / getSessionError

Function getSessionError

packages/webdriver/src/utils.ts:405–456  ·  view source on GitHub ↗
(err: JSONWPCommandError, params: Partial<Options.WebDriver> = {})

Source from the content-addressed store, hash-verified

403 * @param params
404 */
405export const getSessionError = (err: JSONWPCommandError, params: Partial<Options.WebDriver> = {}) => {
406 // browser driver / service is not started
407 if (err.code === 'ECONNREFUSED') {
408 return `Unable to connect to "${params.protocol}://${params.hostname}:${params.port}${params.path}", make sure browser driver is running on that address.` +
409 '\nIt seems like the service failed to start or is rejecting any connections.'
410 }
411
412 if (err.message === 'unhandled request') {
413 return 'The browser driver couldn\'t start the session. Make sure you have set the "path" correctly!'
414 }
415
416 if (!err.message) {
417 return 'See wdio.* logs for more information.'
418 }
419
420 // wrong path: selenium-standalone
421 if (err.message.includes('Whoops! The URL specified routes to this help page.')) {
422 return "It seems you are running a Selenium Standalone server and point to a wrong path. Please set `path: '/wd/hub'` in your wdio.conf.js!"
423 }
424
425 // wrong path: chromedriver, geckodriver, etc
426 if (BROWSER_DRIVER_ERRORS.some(m => err && err.message && err.message.includes(m))) {
427 return "Make sure to set `path: '/'` in your wdio.conf.js!"
428 }
429
430 // edge driver on localhost
431 if (err.message.includes('Bad Request - Invalid Hostname') && err.message.includes('HTTP Error 400')) {
432 return "Run edge driver on 127.0.0.1 instead of localhost, ex: --host=127.0.0.1, or set `hostname: 'localhost'` in your wdio.conf.js"
433 }
434
435 const w3cCapMessage = '\nMake sure to add vendor prefix like "goog:", "appium:", "moz:", etc to non W3C capabilities.' +
436 '\nSee more https://www.w3.org/TR/webdriver/#capabilities'
437
438 // Illegal w3c capability passed to selenium standalone
439 if (err.message.includes('Illegal key values seen in w3c capabilities')) {
440 return err.message + w3cCapMessage
441 }
442
443 // wrong host/port, port in use, illegal w3c capability passed to selenium grid
444 if (err.message === 'Response has empty body') {
445 return 'Make sure to connect to valid hostname:port or the port is not in use.' +
446 '\nIf you use a grid server ' + w3cCapMessage
447 }
448
449 if (err.message.includes('failed serving request POST /wd/hub/session: Unauthorized') && (params.hostname === 'saucelabs.com' || params.hostname?.endsWith('.saucelabs.com'))) {
450 return 'Session request was not authorized because you either did provide a wrong access key or tried to run ' +
451 'in a region that has not been enabled for your user. If have registered a free trial account it is connected ' +
452 'to a specific region. Ensure this region is set in your configuration (https://webdriver.io/docs/options.html#region).'
453 }
454
455 return err.message
456}
457
458/**
459 * Enhance the monad with WebDriver Bidi primitives if a connection can be established successfully

Callers 2

startWebDriverSessionFunction · 0.85
utils.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…