Skip to content

[🐛 Bug]: this[#browser].getContext is not a function TypeError thrown by @wdio/runner #14083

@szarlatan

Description

@szarlatan

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.5.7

Node.js Version

22.12.0

Mode

WDIO Testrunner

Which capabilities are you using?

{
    // capabilities for local Appium web tests on iOS
    platformName: 'iOS',
    browserName: 'Safari',
    'appium:deviceName': 'iPhone 15',
    'appium:platformVersion': '18.0',
    'appium:automationName': 'XCUITest'
}

What happened?

I have setup a simple sample project starting with npm init wdio . After finishing answering questions I've run it with npm run wdio script defined in package.json but it thrown an error ERROR @wdio/runner: TypeError: this[#browser].getContext is not a function. It is not blocking the test run from continuing though.

What is your expected behavior?

I would expect that no errors are thrown during test session initializing as long as correct configuration has been provided.

How to reproduce the bug.

Github project with code reproducing the bug

The problem seems to be related, or the same as described here and here

Relevant log output

╰─$ npm run wdio                                                                                                              1 

> wdio
> wdio run ./wdio.conf.ts


Execution of 1 workers started at 2025-01-17T14:19:58.004Z

2025-01-17T14:19:58.031Z INFO @wdio/cli:launcher: Run onPrepare hook
2025-01-17T14:19:58.041Z INFO @wdio/appium-service: Will spawn Appium process: node /Users/krzysztof.biszta/git/wdiov9/node_modules/appium/index.js --base-path / --port 4723
2025-01-17T14:20:00.249Z INFO @wdio/appium-service: Appium started with ID: 32967
2025-01-17T14:20:00.249Z INFO @wdio/appium-service: Appium logs written to stdout
2025-01-17T14:20:00.251Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2025-01-17T14:20:00.251Z INFO @wdio/local-runner: Start worker 0-0 with arg: run ./wdio.conf.ts
[0-0] 2025-01-17T14:20:00.920Z INFO @wdio/local-runner: Run worker command: run
[0-0] 2025-01-17T14:20:00.926Z ERROR @wdio/runner: TypeError: this[#browser].getContext is not a function
[0-0]     at _ContextManager.initialize (/Users/krzysztof.biszta/git/wdiov9/node_modules/webdriverio/build/index.js:3183:43)
[0-0]     at registerSessionManager (/Users/krzysztof.biszta/git/wdiov9/node_modules/webdriverio/build/index.js:4710:33)
[0-0]     at remote (/Users/krzysztof.biszta/git/wdiov9/node_modules/webdriverio/build/index.js:8165:9)
[0-0]     at async Runner._startSession (file:///Users/krzysztof.biszta/git/wdiov9/node_modules/@wdio/runner/build/index.js:809:23)
[0-0]     at async Runner.run (file:///Users/krzysztof.biszta/git/wdiov9/node_modules/@wdio/runner/build/index.js:670:20)
[0-0] RUNNING in Safari - file:///test/specs/test.e2e.ts
[0-0] 2025-01-17T14:20:01.068Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2025-01-17T14:20:01.068Z INFO @wdio/utils: Connecting to existing driver at http://127.0.0.1:4723/
[0-0] 2025-01-17T14:20:01.074Z INFO webdriver: [POST] http://127.0.0.1:4723/session
[0-0] 2025-01-17T14:20:01.074Z INFO webdriver: DATA {
[0-0]   capabilities: {
[0-0]     alwaysMatch: {
[0-0]       platformName: 'iOS',
[0-0]       browserName: 'Safari',
[0-0]       'appium:deviceName': 'iPhone 15',
[0-0]       'appium:platformVersion': '18.0',
[0-0]       'appium:automationName': 'XCUITest'
[0-0]     },
[0-0]     firstMatch: [ {} ]
[0-0]   }
[0-0] }
2025-01-17T14:21:12.639Z WARN @wdio/appium-service: [139041f1][Xcode] xcodebuild exited with code '65' and signal 'null'

[0-0] 2025-01-17T14:21:47.606Z INFO webdriver: COMMAND getContext()
[0-0] 2025-01-17T14:21:47.606Z INFO webdriver: [GET] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/context
[0-0] 2025-01-17T14:21:47.619Z INFO webdriver: RESULT WEBVIEW_33881.1
[0-0] 2025-01-17T14:21:47.624Z INFO webdriver: COMMAND navigateTo("https://the-internet.herokuapp.com/login")
[0-0] 2025-01-17T14:21:47.624Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/url
[0-0] 2025-01-17T14:21:47.624Z INFO webdriver: DATA { url: 'https://the-internet.herokuapp.com/login' }
[0-0] 2025-01-17T14:21:50.389Z INFO webdriver: RESULT null
[0-0] 2025-01-17T14:21:50.391Z INFO webdriver: COMMAND findElement("css selector", "#username")
[0-0] 2025-01-17T14:21:50.391Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element
[0-0] 2025-01-17T14:21:50.391Z INFO webdriver: DATA { using: 'css selector', value: '#username' }
[0-0] 2025-01-17T14:21:50.408Z INFO webdriver: RESULT {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': ':wdc:1737123710406',
[0-0]   ELEMENT: ':wdc:1737123710406'
[0-0] }
[0-0] 2025-01-17T14:21:50.412Z INFO webdriver: COMMAND elementClear(":wdc:1737123710406")
[0-0] 2025-01-17T14:21:50.413Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element/%3Awdc%3A1737123710406/clear
[0-0] 2025-01-17T14:21:50.429Z INFO webdriver: RESULT null
[0-0] 2025-01-17T14:21:50.430Z INFO webdriver: COMMAND elementSendKeys(":wdc:1737123710406", "<Screenshot[base64]>")
[0-0] 2025-01-17T14:21:50.430Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element/%3Awdc%3A1737123710406/value
[0-0] 2025-01-17T14:21:50.430Z INFO webdriver: DATA { text: 'tomsmith' }
[0-0] 2025-01-17T14:21:50.474Z INFO webdriver: RESULT null
[0-0] 2025-01-17T14:21:50.474Z INFO webdriver: COMMAND findElement("css selector", "#password")
[0-0] 2025-01-17T14:21:50.474Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element
[0-0] 2025-01-17T14:21:50.474Z INFO webdriver: DATA { using: 'css selector', value: '#password' }
[0-0] 2025-01-17T14:21:50.490Z INFO webdriver: RESULT {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': ':wdc:1737123710407',
[0-0]   ELEMENT: ':wdc:1737123710407'
[0-0] }
[0-0] 2025-01-17T14:21:50.493Z INFO webdriver: COMMAND elementClear(":wdc:1737123710407")
[0-0] 2025-01-17T14:21:50.493Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element/%3Awdc%3A1737123710407/clear
[0-0] 2025-01-17T14:21:50.505Z INFO webdriver: RESULT null
[0-0] 2025-01-17T14:21:50.505Z INFO webdriver: COMMAND elementSendKeys(":wdc:1737123710407", "SuperSecretPassword!")
[0-0] 2025-01-17T14:21:50.505Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element/%3Awdc%3A1737123710407/value
[0-0] 2025-01-17T14:21:50.505Z INFO webdriver: DATA { text: 'SuperSecretPassword!' }
[0-0] 2025-01-17T14:21:50.544Z INFO webdriver: RESULT null
[0-0] 2025-01-17T14:21:50.544Z INFO webdriver: COMMAND findElement("css selector", "button[type="submit"]")
[0-0] 2025-01-17T14:21:50.545Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element
[0-0] 2025-01-17T14:21:50.545Z INFO webdriver: DATA { using: 'css selector', value: 'button[type="submit"]' }
[0-0] 2025-01-17T14:21:50.554Z INFO webdriver: RESULT {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': ':wdc:1737123710408',
[0-0]   ELEMENT: ':wdc:1737123710408'
[0-0] }
[0-0] 2025-01-17T14:21:50.556Z INFO webdriver: COMMAND elementClick(":wdc:1737123710408")
[0-0] 2025-01-17T14:21:50.556Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element/%3Awdc%3A1737123710408/click
[0-0] 2025-01-17T14:21:50.601Z INFO webdriver: RESULT null
[0-0] 2025-01-17T14:21:50.602Z INFO webdriver: COMMAND findElement("css selector", "#flash")
[0-0] 2025-01-17T14:21:50.603Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element
[0-0] 2025-01-17T14:21:50.603Z INFO webdriver: DATA { using: 'css selector', value: '#flash' }
[0-0] 2025-01-17T14:21:50.676Z INFO webdriver: RESULT {
[0-0]   error: 'no such element',
[0-0]   message: 'An element could not be located on the page using the given search parameters.',
[0-0]   stacktrace: 'NoSuchElementError: An element could not be located on the page using the given search parameters.\n' +
[0-0]     '    at XCUITestDriver.findWebElementOrElements (/Users/krzysztof.biszta/git/wdiov9/node_modules/appium-xcuitest-driver/lib/commands/web.js:444:13)\n' +
[0-0]     '    at XCUITestDriver.findElOrEls (/Users/krzysztof.biszta/git/wdiov9/node_modules/appium-xcuitest-driver/lib/commands/find.js:22:14)\n' +
[0-0]     '    at XCUITestDriver.findElOrElsWithProcessing (/Users/krzysztof.biszta/git/wdiov9/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:60:12)\n' +
[0-0]     '    at XCUITestDriver.findElement (/Users/krzysztof.biszta/git/wdiov9/node_modules/@appium/base-driver/lib/basedriver/commands/find.ts:75:12)'
[0-0] }
[0-0] 2025-01-17T14:21:50.679Z INFO webdriver: COMMAND findElements("css selector", "#flash")
[0-0] 2025-01-17T14:21:50.679Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/elements
[0-0] 2025-01-17T14:21:50.679Z INFO webdriver: DATA { using: 'css selector', value: '#flash' }
[0-0] 2025-01-17T14:21:50.710Z INFO webdriver: RESULT []
[0-0] 2025-01-17T14:21:51.213Z INFO webdriver: COMMAND findElements("css selector", "#flash")
[0-0] 2025-01-17T14:21:51.213Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/elements
[0-0] 2025-01-17T14:21:51.213Z INFO webdriver: DATA { using: 'css selector', value: '#flash' }
[0-0] 2025-01-17T14:21:51.218Z INFO webdriver: RESULT []
[0-0] 2025-01-17T14:21:51.721Z INFO webdriver: COMMAND findElements("css selector", "#flash")
[0-0] 2025-01-17T14:21:51.721Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/elements
[0-0] 2025-01-17T14:21:51.721Z INFO webdriver: DATA { using: 'css selector', value: '#flash' }
[0-0] 2025-01-17T14:21:51.728Z INFO webdriver: RESULT [
[0-0]   {
[0-0]     'element-6066-11e4-a52e-4f735466cecf': ':wdc:1737123711726',
[0-0]     ELEMENT: ':wdc:1737123711726'
[0-0]   }
[0-0] ]
[0-0] 2025-01-17T14:21:51.731Z INFO webdriver: COMMAND findElement("css selector", "#flash")
[0-0] 2025-01-17T14:21:51.731Z INFO webdriver: [POST] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element
[0-0] 2025-01-17T14:21:51.731Z INFO webdriver: DATA { using: 'css selector', value: '#flash' }
[0-0] 2025-01-17T14:21:51.737Z INFO webdriver: RESULT {
[0-0]   'element-6066-11e4-a52e-4f735466cecf': ':wdc:1737123711726',
[0-0]   ELEMENT: ':wdc:1737123711726'
[0-0] }
[0-0] 2025-01-17T14:21:51.738Z INFO webdriver: COMMAND getElementText(":wdc:1737123711726")
[0-0] 2025-01-17T14:21:51.739Z INFO webdriver: [GET] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2/element/%3Awdc%3A1737123711726/text
[0-0] 2025-01-17T14:21:51.749Z INFO webdriver: RESULT You logged into a secure area!
[0-0] ×
[0-0] 2025-01-17T14:21:51.751Z INFO webdriver: COMMAND deleteSession()
[0-0] 2025-01-17T14:21:51.751Z INFO webdriver: [DELETE] http://127.0.0.1:4723/session/139041f1-c2b8-47c9-af96-7ba5a7b3b2c2
2025-01-17T14:21:53.582Z WARN @wdio/appium-service: [139041f1][Xcode] xcodebuild exited with code '75' and signal 'null'

[0-0] 2025-01-17T14:21:58.136Z INFO webdriver: RESULT null
[0-0] PASSED in Safari - file:///test/specs/test.e2e.ts
2025-01-17T14:21:58.246Z INFO @wdio/cli:launcher: Run onWorkerEnd hook

 "spec" Reporter:
------------------------------------------------------------------
[Safari iOS #0-0] Running: Safari on iOS
[Safari iOS #0-0] Session ID: 139041f1-c2b8-47c9-af96-7ba5a7b3b2c2
[Safari iOS #0-0]
[Safari iOS #0-0] » /test/specs/test.e2e.ts
[Safari iOS #0-0] My Login application
[Safari iOS #0-0]     should login with valid credentials
[Safari iOS #0-0]
[Safari iOS #0-0] 1 passing (10.5s)


Spec Files:      1 passed, 1 total (100% completed) in 00:02:00  

2025-01-17T14:21:58.247Z INFO @wdio/local-runner: Shutting down spawned worker
2025-01-17T14:21:58.498Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2025-01-17T14:21:58.499Z INFO @wdio/local-runner: shutting down
2025-01-17T14:21:58.499Z INFO @wdio/cli:launcher: Run onComplete hook
2025-01-17T14:21:58.499Z INFO @wdio/appium-service: Killing entire Appium tree
2025-01-17T14:21:58.537Z INFO @wdio/appium-service: Process and its children successfully terminated

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions