在Android设备上使用WebdriverIO与Appium时出现会话错误



我克隆了回购https://github.com/Schveitzer/webdriverio-appium-cucumber-boilerplate并尝试运行测试。我总是得到以下错误:

2022-06-16T22:51:13.157Z ERROR @wdio/runner: Error: Failed to create session.
Unable to connect to "http://localhost:4723/", 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.

步骤:

  1. 克隆repo
  2. 下载最新版本的demo应用,Android-NativeDemoApp-0.4.0.apk。
  3. 更新功能
  4. Yarn Install/Yarn Run

我做了一些改变。然而,无法解决这个问题。有什么建议可以解决这个问题吗?

从错误来看,似乎appium服务器没有运行。一个原因可能是repo有一个旧版本的软件包,而你可能已经安装了最新版本的appium。

你可以尝试的一件事是从配置文件中删除这一行,并尝试下面的操作。

  1. 在终端
  2. 上使用appium命令启动appium服务器
  3. 运行测试,看看是否有效

否则,您必须升级repo中的所有包。但这也意味着你可能需要修改代码中的某些内容。

您的appium服务器可能没有运行,从包。我可以看到应该启动它的appium-service丢失了。您有两个选项:

  1. 安装@wdio/appium-service包,appium会自动运行或者
  2. 自己启动appium服务器,要么从终端使用appium -a 127.0.0.1 -p 4723启动,要么启动appium桌面应用

WebDriverIO无法连接到运行在http://127.0.0.1:4723/上的Appium服务器。

解决这个问题的几个步骤:

  1. 检查Appium服务器是否在http://127.0.0.1:4723/上运行。你可以打开网页浏览器,导航到http://127.0.0.1:4723。如果服务器正在运行,您应该看到指示服务器正在运行并准备接受的消息连接。
  2. 检查chromedriver可执行文件是否已安装并在系统的路径。WebDriverIO使用chromedriver与Android设备上的Chrome浏览器。您可以安装chromedriver通过运行以下命令来使用npm:
npm install -g chromedriver
  1. 检查@wdio/appium-service是否包含在服务中在wdio.conf.js文件中:
services: ['appium']

最新更新