我正在使用 WebDriverIO 和 Appium 运行测试套件来自动化 Android 应用程序测试。我的测试套件在第一次执行时成功运行,但在第二次执行时,我收到“Appium 在超时前退出”错误。第三次执行运行良好,但第四次执行再次出现同样的错误。
这是我对 package.json 的开发依赖
"devDependencies": {
"@wdio/appium-service": "^8.8.8",
"@wdio/cli": "^8.8.8",
"@wdio/local-runner": "^8.8.8",
"@wdio/mocha-framework": "^8.8.7",
"@wdio/spec-reporter": "^8.8.7",
"appium": "^2.0.0-beta.66",
"appium-uiautomator2-driver": "^2.23.0"
},
这是我从 wdio.const.js 获得的功能:
capabilities: [
{
platformName: 'Android',
'appium:platformVersion': '13.0',
'appium:deviceName': 'Pixel_3a_API_33_x86_64',
'appium:automationName': 'UIAutomator2',
'appium:app': `${join(
process.cwd(),
'./app/android/ApiDemos-debug.apk'
)}`,
},
],
这里是完整的错误:
Execution of 1 workers started at 2023-05-04T13:02:35.362Z
2023-05-04T13:02:35.474Z INFO @wdio/cli:launcher: Run onPrepare hook
2023-05-04T13:02:54.654Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: Appium exited before timeout (exit code: 1)
at ChildProcess.<anonymous> (file:///C:/Users/asus/VS%20Projects/webdriverio-appium-v8/node_modules/@wdio/appium-service/build/launcher.js:116:22)
at Object.onceWrapper (node:events:642:26)
at ChildProcess.emit (node:events:527:28)
at ChildProcess.emit (node:domain:475:12)
at ChildProcess._handle.onexit (node:internal/child_process:291:12)
Continue...
2023-05-04T13:02:54.663Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2023-05-04T13:02:54.666Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,wdio.conf.js
[0-0] 2023-05-04T13:02:59.905Z INFO @wdio/local-runner: Run worker command: run
[0-0] RUNNING in Android - file:///C:/Users/asus/VS%20Projects/webdriverio-appium-v8/test/specs/android-findElemets.spec.js
[0-0] 2023-05-04T13:03:00.736Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2023-05-04T13:03:01.511Z INFO webdriver: [POST] http://127.0.0.1:4723/session
[0-0] 2023-05-04T13:03:01.512Z INFO webdriver: DATA {
[0-0] capabilities: {
[0-0] alwaysMatch: {
[0-0] platformName: 'Android',
[0-0] 'appium:platformVersion': '13.0',
[0-0] 'appium:deviceName': 'Pixel_3a_API_33_x86_64',
[0-0] 'appium:automationName': 'UIAutomator2',
[0-0] 'appium:app': 'C:\\Users\\asus\\VS Projects\\webdriverio-appium-v8\\app\\android\\ApiDemos-debug.apk'
[0-0] },
[0-0] firstMatch: [ {} ]
[0-0] },
[0-0] desiredCapabilities: {
[0-0] platformName: 'Android',
[0-0] 'appium:platformVersion': '13.0',
[0-0] 'appium:deviceName': 'Pixel_3a_API_33_x86_64',
[0-0] 'appium:automationName': 'UIAutomator2',
[0-0] 'appium:app': 'C:\\Users\\asus\\VS Projects\\webdriverio-appium-v8\\app\\android\\ApiDemos-debug.apk'
[0-0] }
[0-0] }
[0-0] 2023-05-04T13:03:04.831Z ERROR webdriver: RequestError: read ECONNRESET
[0-0] at ClientRequest.<anonymous> (file:///C:/Users/asus/VS%20Projects/webdriverio-appium-v8/node_modules/got/dist/source/core/index.js:789:107)
[0-0] at Object.onceWrapper (node:events:642:26)
[0-0] at ClientRequest.emit (node:events:539:35)
[0-0] at ClientRequest.emit (node:domain:475:12)
[0-0] at Socket.socketErrorListener (node:_http_client:454:9)
[0-0] at Socket.emit (node:events:527:28)
[0-0] at Runner.run (file:///C:/Users/asus/VS%20Projects/webdriverio-appium-v8/node_modules/@wdio/runner/build/index.js:77:19)
[0-0] FAILED in Android - file:///C:/Users/asus/VS%20Projects/webdriverio-appium-v8/test/specs/android-findElemets.spec.js
2023-05-04T13:03:04.990Z INFO @wdio/cli:launcher: Run onWorkerEnd hook
2023-05-04T13:03:04.993Z INFO @wdio/cli:launcher: Run onComplete hook
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:29
2023-05-04T13:03:04.996Z INFO @wdio/local-runner: Shutting down spawned worker
2023-05-04T13:03:05.258Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2023-05-04T13:03:05.260Z INFO @wdio/local-runner: shutting down
我不确定为什么每次运行测试套件时都会出现此错误。可能是什么原因导致此问题?我该如何解决?
我删除并重新安装了node_modules和package-lock.json文件。但这没有用。我还想指出,当我使用本地安装的 appium 包时,我遇到了同样的错误。
你找出问题所在了吗?