May 25, 2020

WebdriverIO - Appium, The "Error: Failed to create session."

Working on a hybrid app built with Ionic4, I've been writing tests with Angular's e2e, cucumber and selenium, now I'm surprised by variety of features & supported services offered by webdriverio.

I first went into the list of boilerplate projects and try to get my hand dirty with first sample project made for hybrid app.

I git cloned this repo - appium-boilerplate, updated capabilities values based on the simulator config available on my dev environment (you have to provide exact to the capabilities based on your AVD Manager - Android Studio).

Next, by running the command "npm run android.app", I'd expected appium magic would works instantly, but if as a first-timer-of-all-stuff, I ran into a little issue (but cost all day to find out the causes).


Troubleshooting

If you run into similar error message as following:

Error: Failed to create session.
read ECONNRESET    
  
    npm run android.app

    appium-boilerplate@5.3.1 android.app ~/appium-boilerplate
    wdio ./config/wdio.android.app.conf.js


    Execution of 6 spec files started at 2020-05-24T05:09:03.689Z

    [0-0] RUNNING in Android - /tests/specs/app.forms.spec.js
    [0-0]  Error:  Failed to create session.
    read ECONNRESET
    [0-0] FAILED in Android - /tests/specs/app.forms.spec.js
    [0-1] RUNNING in Android - /tests/specs/app.login.spec.js
    [0-1]  Error:  Failed to create session.
    read ECONNRESET
    [0-1] FAILED in Android - /tests/specs/app.login.spec.js
    [0-2] RUNNING in Android - /tests/specs/app.navigation.spec.js
    [0-2]  Error:  Failed to create session.
    read ECONNRESET
    [0-2] FAILED in Android - /tests/specs/app.navigation.spec.js
    [0-3] RUNNING in Android - /tests/specs/app.swipe.spec.js
    [0-3]  Error:  Failed to create session.
    read ECONNRESET
    [0-3] FAILED in Android - /tests/specs/app.swipe.spec.js
    [0-4] RUNNING in Android - /tests/specs/app.webview.spec.js
    [0-4]  Error:  Failed to create session.
    read ECONNRESET
    [0-4] FAILED in Android - /tests/specs/app.webview.spec.js
    [0-5] RUNNING in Android - /tests/specs/app.webview.xpath.spec.js
    [0-5]  Error:  Failed to create session.
    read ECONNRESET
    [0-5] FAILED in Android - /tests/specs/app.webview.xpath.spec.js

    Spec Files:  0 passed, 6 failed, 6 total (100% completed) in 00:02:07 

    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! appium-boilerplate@5.3.1 android.app: `wdio ./config/wdio.android.app.conf.js`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the appium-boilerplate@5.3.1 android.app script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     ~/.npm/_logs/2020-05-24T05_11_11_738Z-debug.log
  

Solution

I couldn't believe it (that's reason it costed my days to resolve it) until I tried it.
Start and run your virtual device (simulator) first before the webdriverio's command (npm run android.app)

Futhermore, you can always add another logPath as appium services' option, so you can look into the error log for troubleshooting.  

No comments:

Post a Comment

Hey, thank you for spending time leaving some thoughts, that would be really helpful as encouragement for us to write more quality articles! Thank you!