5

I want to execute a mobile automation test that has been written in Javascript. I am using Appium and android-studio. I determined the capabilities in the wdio.config.js file as shown below.

capabilities: [{

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

}]

The emulator is opened in the Android-studio, and I determined the device name in capabilities as shown above. However, when I run the code I have the error as shown below::

 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.
programmer
  • 577
  • 1
  • 9
  • 21

0 Answers0