针对移动应用程序运行时,节点 18 出现无法连接到“http://localhost:4723/wd/hub”错误

问题描述 投票:0回答:1

我有基于 webdriverio + cucumberjs 的测试,当使用节点 18 时,我收到错误 -

http://localhost:4723/wd/hub
设置:

node v18.20.3 (npm v10.7.0)
[email protected]
[email protected]

我能够在 iOS safari 浏览器上运行,但无法在任何移动应用程序上运行。但当我使用节点 16 时,我的相同测试也有效。

node v16.20.2 (npm v8.19.4)
[email protected]
[email protected]

错误日志:

Unable to connect to "http://localhost:4723/wd/hub", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
    at Runtime.runTestRunHooks (/private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/@cucumber/cucumber/lib/runtime/run_test_run_hooks.js:23:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Runtime.start (/private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/@cucumber/cucumber/lib/runtime/index.js:53:9)
    at async runCucumber (/private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/@cucumber/cucumber/lib/api/run_cucumber.js:106:21) {
  jse_shortmsg: 'a BeforeAll hook errored, process exiting: node_modules/<my-package>/dist/myfile.js:72',
  jse_cause: Error: Failed to create session.
  Unable to connect to "http://localhost:4723/wd/hub", make sure browser driver is running on that address.
  If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
      at startWebDriverSession (file:///private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/webdriver/build/utils.js:68:15)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async WebDriver.newSession (file:///private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/webdriver/build/index.js:26:45)
      at async remote (file:///private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/webdriverio/build/index.js:48:22),
  jse_info: {},
  cause: [Function: ve_cause]
node.js webdriver-io appium-ios cucumberjs xcuitest
1个回答
0
投票

Appium 不再使用“/wd/hub”,或者至少它不需要外部使用。

这是启动 Appium 时 Appium 2.11 服务器命令的输出:

[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLs in your client code to connect to this server:
    http://127.0.0.1:4723/ (only accessible from the same host)

当我运行 2.0 之前的 Appium 服务器时,它曾经显示输出中包含的“/wd/hub”(至少我记得是这样)。

作为参考,我尝试在没有 Appium 服务器的情况下运行测试,这是我的错误:

Unable to connect to "http://0.0.0.0:4723/", make sure browser driver is running on that address.

如您所见,它正在尝试访问没有“wd/hub”的 URL。 我不确定它是否有帮助,但我明确记得省略了“wd/hub”。希望有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.