Appium JS Testing

Appium JS Testing

Automation with M-Live Connect enables you to test native and hybrid mobile applications using the Appium automation framework. It’s easy to run your Appium tests written using NodeJS, WebDriverIO, CucumberJS, Gauge and WD on real Android/iOS devices on Momentum Suite. In this guide, you will learn how to test with WebDriverIO.

  1. Check requirements
  2. Create your account
  3. Upload your app
  4. Clone sample code
  5. Configure and run your first test
  6. View test execution results
  1. Check requirements:
    • WebdriverIO v7 requires Node.js version 14 or higher. If you don’t have Node installed, download it from here.
    • Install the Allure command-line tool, to process the results directory after the test run.
    • You will need access to your Android app (.apk or .aab file) or iOS app (.ipa file) for app testing.
  2. Create your account:
    • You will need a Momentum Suite user and token. If you haven’t created an account yet, sign up for a free trial or purchase a paid plan.
    • After signup, you can obtain your access credentials from the device info popup on any device.
  3. Upload your app:
    • Upload your Android app (.apk or .aab file) or iOS app (.ipa file) to Momentum Suite servers using our GUI. Go to Application Library and Upload your app file.
    • Example uploaded file URL format will be ms://d3fb… You can use it as your Appium’s app capability value.
    • We will automatically resign your IPA iOS file with ours.
    • Optionally you can use a publicly accessible web URL.
  4. Clone sample code:
 
git clone https://github.com/momentumsuite/webdriverio-mocha-appium-momentumsuite.git

 
  • Run the following command in the project’s base directory to install all dependency packages.
 
npm i

 

  1. Configure and run your first test:
var DATA = {   
    CLOUD : {
       "momentum.user": "<momentum-suite-username>",
       "momentum.token": "<momentum-suite-access-key>",
       "momentum.app": "ms://<hashed-app-id>", 
       "momentum.hostname": "console.momentumsuite.com",
       "momentum.port": 443,
       "momentum.path": "/gateway/wd/hub/",
       "momentum.protocol": "https",
       "momentum.deviceList": [momentum-suite-device-id] //Comma seperated device list for parallel-test run
       },
   
   LOCAL : {
       "app": "https://momentumsuite.com/downloads/sample.apk",
       "hostname": "127.0.0.1",
       "port": 4723,
       "path": "/wd/hub/",
       "protocol": "http",
       "deviceName": "emulator-5554"
       }
   };
   
   exports.DATA = DATA;
  • user (momentum-suite-username), Usually it could be your login email address
  • token (momentum-suite-access-key), Your unique access token learned from momentumsuite.com device-info popup
  • gw (momentum-suite-device-id), Comma-separated Momentum Suite mobile device ID list (4 digit number) to run the test. The first number will be your default phone for all except parallel testing.
  • app (ms://hashed-app-id), Your uploaded IPA, APK or AAB app file from Momentum Suite Application Library. The example format is ms:// Optionally you can use a publicly accessible web URL.
  • This is the sample code part for Appium Capabilities. Do not set deviceName and udid capability values and send an empty value for both. We will handle this for the cloud with gw appium capability option. 4-digit unique numbers were used, Learn deviceId from device info popup and update it on test-settings.js file within the array list.
AndroidiOS
capabilities: [{
        platformName: "Android",
        "appium:app": DATA.CLOUD['momentum.app'],
        "appium:automationName": "UiAutomator2",
        "appium:autoGrantPermissions": true,
        "appium:language": "en",
        "appium:locale": "en",
        "appium:fullReset": true,
        "appium:noReset": false,
        "appium:deviceName": "",
        "appium:udid": "",
        "momentum:options": {
            "user": DATA.CLOUD['momentum.user'],
            "token": DATA.CLOUD['momentum.token'],
            "gw": DATA.CLOUD['momentum.deviceList'][0]
        }
    }],
capabilities: [{
        platformName: "iOS",
        "appium:app": DATA.CLOUD['momentum.app'],
        "appium:automationName": "XCUITest",
        "appium:autoAcceptAlerts": true,
        "appium:language": "en",
        "appium:locale": "en",
        "appium:fullReset": true,
        "appium:noReset": false,
        "appium:deviceName": "",
        "appium:udid": "",
        "appium:remoteDebugProxy": "gw+2000",
        "momentum:options": {
            "user": DATA.CLOUD['momentum.user'],
            "token": DATA.CLOUD['momentum.token'],
            "gw": DATA.CLOUD['momentum.deviceList'][0]
        }
    }],
  • Run the following command in the project’s base directory to run the Android getting started project :
npm run android-first


  • Run the following command in the project’s base directory to run the iOS getting started project :
npm run ios-first


All other available commands to start mobile testing:

AndroidiOS
npm run android-first
npm run android-parallel
npm run android-local
npm run android-pom
npm run android-cucumber
npm run android-multiple
npm run android-chrome
npm run ios-first
npm run ios-parallel
npm run ios-local
npm run ios-pom
npm run ios-cucumber
npm run ios-multiple
npm run ios-safari
  1. View test execution results

Run the following command in the project’s base directory after the completed test run. This command will open a browser window with HTML test results.

allure open

Related Posts