Javascript 错误webdriver:RequestError:connect-EconRefuse127.0.0.1:4444

Javascript 错误webdriver:RequestError:connect-EconRefuse127.0.0.1:4444,javascript,android,android-studio,appium,appium-desktop,Javascript,Android,Android Studio,Appium,Appium Desktop,我想执行一个用Javascript编写的移动自动化测试。我正在使用Appium和android studio。我确定了wdio.config.js文件中的功能,如下所示 能力:[{ "browserName": "Android", "maxInstances": 1, "platform": "ANDROID", "appium:deviceName&q

我想执行一个用Javascript编写的移动自动化测试。我正在使用Appium和android studio。我确定了wdio.config.js文件中的功能,如下所示

能力:[{

    "browserName": "Android",
    "maxInstances": 1,
    "platform": "ANDROID",
    "appium:deviceName": "Pixel 3a",
    "appium:app": "./Api.apk", 
}]

emulator在Android studio中打开,我在capabilities中确定了设备名称,如上图所示。但是,当我运行代码时,出现如下所示的错误:

 appium_js@1.0.0 test /home/aaa/Desktop/mobile/appium_js
 wdio wdio.conf.js


Execution of 1 spec files started at 2020-11-16T17:41:06.466Z

2020-11-16T17:41:06.480Z INFO @wdio/cli:launcher: Run onPrepare hook
Starting ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
2020-11-16T17:41:06.599Z INFO @wdio/cli:launcher: Run onWorkerStart hook
2020-11-16T17:41:06.602Z INFO @wdio/local-runner: Start worker 0-0 with arg: wdio.conf.js
[0-0] 2020-11-16T17:41:06.981Z INFO @wdio/local-runner: Run worker command: run
[0-0] 2020-11-16T17:41:06.997Z INFO webdriverio: Initiate new session using the ./protocol-stub protocol
[0-0] RUNNING in Android - /test/specs/sample_test.js
[0-0] 2020-11-16T17:41:07.132Z INFO webdriverio: Initiate new session using the webdriver protocol
[0-0] 2020-11-16T17:41:07.134Z INFO webdriver: [POST] http://localhost:4444/session
[0-0] 2020-11-16T17:41:07.134Z INFO webdriver: DATA {
  capabilities: {
    alwaysMatch: {
      browserName: 'Android',
      platform: 'ANDROID',
      'appium:deviceName': 'Pixel 3a',
      'appium:app': '/home/aaa/Desktop/mobile/appium_js/ApiDemos-debug.apk'
    },
    firstMatch: [ {} ]
  },
  desiredCapabilities: {
    browserName: 'Android',
    platform: 'ANDROID',
    'appium:deviceName': 'Pixel 3a',
    'appium:app': '/home/aaa/Desktop/mobile/appium_js/ApiDemos-debug.apk'
  }
}
[0-0] 2020-11-16T17:41:07.158Z ERROR webdriver: RequestError: connect ECONNREFUSED 127.0.0.1:4444
    at ClientRequest.<anonymous> (/home/aaa/Desktop/mobile/appium_js/node_modules/got/dist/source/core/index.js:953:111)
    at Object.onceWrapper (events.js:421:26)
    at ClientRequest.emit (events.js:326:22)
    at ClientRequest.EventEmitter.emit (domain.js:486:12)
    at ClientRequest.origin.emit (/home/aaa/Desktop/mobile/appium_js/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
    at Socket.socketErrorListener (_http_client.js:469:9)
    at Socket.emit (events.js:314:20)
    at Socket.EventEmitter.emit (domain.js:486:12)
    at emitErrorNT (internal/streams/destroy.js:100:8)
    at emitErrorCloseNT (internal/streams/destroy.js:68:3)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)
[0-0] 2020-11-16T17:41:07.159Z ERROR @wdio/runner: Error: Failed to create session.
Unable to connect to "http://localhost:4444/", 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 Object.startWebDriverSession (/home/aaa/Desktop/mobile/appium_js/node_modules/webdriver/build/utils.js:34:15)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Function.newSession (/home/aaaDesktop/mobile/appium_js/node_modules/webdriver/build/index.js:30:45)
    at async Object.exports.remote (/home/aaa/Desktop/mobile/appium_js/node_modules/webdriverio/build/index.js:60:22)
    at async Runner._startSession (/home/aaa/Desktop/mobile/appium_js/node_modules/@wdio/runner/build/index.js:128:56)
    at async Runner._initSession (/home/aaa/Desktop/mobile/appium_js/node_modules/@wdio/runner/build/index.js:108:25)
    at async Runner.run (/home/aaa/Desktop/mobile/appium_js/node_modules/@wdio/runner/build/index.js:52:19)
[0-0]  Error:  Failed to create session.
Unable to connect to "http://localhost:4444/", 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.
[0-0] FAILED in Android - /test/specs/sample_test.js
2020-11-16T17:41:07.268Z INFO @wdio/cli:launcher: Run onComplete hook

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

2020-11-16T17:41:07.269Z INFO @wdio/local-runner: Shutting down spawned worker
2020-11-16T17:41:07.520Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
2020-11-16T17:41:07.521Z INFO @wdio/local-runner: shutting down
npm ERR! Test failed.  See above for more details.
appium_js@1.0.0test/home/aaa/Desktop/mobile/appium_js
wdio wdio.conf.js
从2020-11-16T17:41:06.466Z开始执行1个规范文件
2020-11-16T17:41:06.480Z INFO@wdio/cli:launcher:runonprepare-hook
9515端口上的启动ChromeDriver 86.0.4240.22(398b0743353ff36fb1b82468f63a3a93b4e2e89e参考/分支头/4240{378})
只允许本地连接。
请看https://chromedriver.chromium.org/security-considerations 获取有关确保ChromeDriver安全的建议。
ChromeDriver已成功启动。
2020-11-16T17:41:06.599Z INFO@wdio/cli:launcher:runonworkerstart-hook
2020-11-16T17:41:06.602Z INFO@wdio/local runner:使用arg:wdio.conf.js启动worker 0-0
[0-0]2020-11-16T17:41:06.981Z INFO@wdio/local runner:Run worker命令:Run
[0-0]2020-11-16T17:41:06.997Z信息网络驱动器:使用./protocol存根协议启动新会话
[0-0]在Android中运行-/test/specs/sample_test.js
[0-0]2020-11-16T17:41:07.132Z信息网络驱动:使用网络驱动协议启动新会话
[0-0]2020-11-16T17:41:07.134Z信息网络驱动程序:[发布]http://localhost:4444/session
[0-0]2020-11-16T17:41:07.134Z信息网络驱动程序:数据{
能力:{
alwaysMatch:{
browserName:“Android”,
平台:“安卓”,
'appium:deviceName':'Pixel 3a',
“appium:app”:“/home/aaa/Desktop/mobile/appium_js/ApiDemos debug.apk”
},
firstMatch:[{}]
},
所需能力:{
browserName:“Android”,
平台:“安卓”,
'appium:deviceName':'Pixel 3a',
“appium:app”:“/home/aaa/Desktop/mobile/appium_js/ApiDemos debug.apk”
}
}
[0-0]2020-11-16T17:41:07.158Z错误webdriver:RequestError:connect-EconRefused 127.0.0.1:4444
在ClientRequest。(/home/aaa/Desktop/mobile/appium_js/node_modules/got/dist/source/core/index.js:953:111)
在Object.onceWrapper(events.js:421:26)
在ClientRequest.emit(events.js:326:22)
在ClientRequest.EventEmitter.emit(domain.js:486:12)
在ClientRequest.origin.emit(/home/aaa/Desktop/mobile/appium_js/node_modules/@szmarczak/http timer/dist/source/index.js:39:20)
位于Socket.socketErrorListener(_http_client.js:469:9)
在Socket.emit(events.js:314:20)
位于Socket.EventEmitter.emit(domain.js:486:12)
发射错误(内部/streams/destroy.js:100:8)
在emitErrorCloseNT(内部/streams/destroy.js:68:3)
在TCPConnectWrap.afterConnect[as oncomplete](net.js:1144:16)
[0-0]2020-11-16T17:41:07.159Z错误@wdio/runner:错误:创建会话失败。
无法连接到“http://localhost:4444/,请确保浏览器驱动程序正在该地址上运行。
如果您使用chromedriver之类的服务,请参阅上面或wdio.log文件中的initialiseServices日志,因为该服务在启动驱动程序时可能会遇到问题。
在Object.startwebdriversation(/home/aaa/Desktop/mobile/appium_js/node_modules/webdriver/build/utils.js:34:15)
在处理和拒绝时(内部/process/task_queues.js:93:5)
在async Function.newSession(/home/aaaDesktop/mobile/appium_js/node_modules/webdriver/build/index.js:30:45)
在async Object.exports.remote(/home/aaa/Desktop/mobile/appium_js/node_modules/webdriverio/build/index.js:60:22)
异步运行时启动会话(/home/aaa/Desktop/mobile/appium\u js/node\u modules/@wdio/Runner/build/index.js:128:56)
异步Runner.\u initSession(/home/aaa/Desktop/mobile/appium\u js/node\u modules/@wdio/Runner/build/index.js:108:25)
在async Runner.run(/home/aaa/Desktop/mobile/appium_js/node_modules/@wdio/Runner/build/index.js:52:19)
[0-0]错误:无法创建会话。
无法连接到“http://localhost:4444/,请确保浏览器驱动程序正在该地址上运行。
如果您使用chromedriver之类的服务,请参阅上面或wdio.log文件中的initialiseServices日志,因为该服务在启动驱动程序时可能会遇到问题。
[0-0]在Android-/test/specs/sample_test.js中失败
2020-11-16T17:41:07.268Z INFO@wdio/cli:launcher:runoncomplete钩子
规格文件:0个通过,1个失败,00:00:00内总共1个(100%完成)
2020-11-16T17:41:07.269Z INFO@wdio/local runner:关闭生成的工作程序
2020-11-16T17:41:07.520Z INFO@wdio/本地跑步者:等待0正常关闭
2020-11-16T17:41:07.521Z信息@wdio/本地跑步者:关闭
npm错误!测试失败。请参见上文了解更多详细信息。