Page tree
Skip to end of metadata
Go to start of metadata

Experitest cloud platform lets you execute Appium tests on remotely located devices. If you have existing Appium tests written in javascript that you have been running locally, or if you want to start testing using javascript and Node.js then you've come to the right place. This page discusses how to prepare and execute Appium tests using javascript and Node.js.

You could make use of our sample tests in our git repository by forking it or using the sample tests below.

Set Experitest Url

Please make sure you replace <EXPERITEST_URL> with appropriate URL in the sample tests below.

Android App Testing using Javascript
"use strict";
var webdriverio = require('webdriverio');
 
function main() {
 
  let options = {
    host: 'cloud.seetest.io',
    protocol: 'https',
    port: 443,
    path: '', 
    desiredCapabilities: {
        accessKey: "<ACCESS_KEY>",
        platformName: 'android',
        //udid: "<UDID OF SPECIFIC DEVICE>", optional
        app: "http://d242m5chux1g9j.cloudfront.net/eribank.apk", // if you have the app in your project you can do cloud:com.pacakge.name
        appPackage: "com.experitest.ExperiBank",
        appActivity: ".LoginActivity",
        testName: "Javascript Android App Test"
      }
  };
 
  webdriverio
    .remote(options)
    .init()
    .setValue("//*[@id='usernameTextField']", "company")
    .setValue("//*[@id='passwordTextField']", "company")
    .click("//*[@id='loginButton']")
    .click("//*[@id='makePaymentButton']")
    .setValue("//*[@id='phoneTextField']", "123456")
    .setValue("//*[@id='nameTextField']", "Test")
    .setValue("//*[@id='amountTextField']", "10")
    .setValue("//*[@id='countryTextField']", "US")
    .click("//*[@id='sendPaymentButton']")
    .click("//*[@id='button1']")
    .click("//*[@id='logoutButton']")
    .end()
    .catch(function (err) {
        console.log(err);
    });
  }
 
main();
IOS App Testing using Javascript
"use strict";
var webdriverio = require('webdriverio');
 
function main() {
 
  let options = {
    host: 'cloud.seetest.io',
    protocol: 'https',
    port: 443,
    path: '', 
    desiredCapabilities: {
        accessKey: "<ACCESS_KEY>",
        platformName: 'ios',
        //udid: "<UDID OF SPECIFIC DEVICE>", optional
        app: "http://d242m5chux1g9j.cloudfront.net/EriBank.ipa", // if you have the app in your project you can do cloud:com.pacakge.name
        bundleId: "com.experitest.ExperiBank", // would be appPackage and appActivity for Android
        testName: "Javascript iOS App Test"
      }
  };
 
  webdriverio
    .remote(options)
    .init()
    .setValue("//*[@id='usernameTextField']", "company")
    .setValue("//*[@id='passwordTextField']", "company")
    .click("//*[@id='loginButton']")
    .click("//*[@id='makePaymentButton']")
    .setValue("//*[@id='phoneTextField']", "123456")
    .setValue("//*[@id='nameTextField']", "Test")
    .setValue("//*[@id='amountTextField']", "10")
    .setValue("//*[@id='countryTextField']", "US")
    .click("//*[@id='sendPaymentButton']")
    .click("//*[@id='Yes']")
    .click("//*[@id='logoutButton']")
    .end()
    .catch(function (err) {
        console.log(err);
    });
  }
 
main();
Chrome on Android Test using Javascript
"use strict";
var webdriverio = require('webdriverio');
 
function main() {
 
  let options = {
    host: 'cloud.seetest.io',
    protocol: 'https',
    port: 443,
    path: '', 
    desiredCapabilities: {
        accessKey: "<ACCESS_KEY>",
        platformName: 'android',
        browserName: 'chrome',
        //udid: "<UDID OF SPECIFIC DEVICE>", optional
        testName: "Javascript Android Web Test"
      }
  };
 
  webdriverio
    .remote(options)
    .init()
    .url("https://ebay.com")
    .setValue("//*[@id='kw']", "iPhone")
    .click("//*[@id='ghs-submit']")
    .pause(2000)
    .getTitle().then(function(title){
      console.log("The title of the page is: ", title);
    })
    .end()
    .catch(function (err) {
        console.log(err);
    });
  }
 
main();
Safari on IOS Test using Javascript
"use strict";
var webdriverio = require('webdriverio');
 
function main() {
 
  let options = {
    host: 'cloud.seetest.io',
    protocol: 'https',
    port: 443,
    path: '', 
    desiredCapabilities: {
        accessKey: "<ACCESS_KEY>",
        platformName: 'ios',
        //udid: "<UDID OF SPECIFIC DEVICE>", optional
        app: "http://d242m5chux1g9j.cloudfront.net/EriBank.ipa", // if you have the app in your project you can do cloud:com.pacakge.name
        bundleId: "com.experitest.ExperiBank", // would be appPackage and appActivity for Android
        testName: "Javascript iOS App Test"
      }
  };
 
  webdriverio
    .remote(options)
    .init()
    .setValue("//*[@id='usernameTextField']", "company")
    .setValue("//*[@id='passwordTextField']", "company")
    .click("//*[@id='loginButton']")
    .click("//*[@id='makePaymentButton']")
    .setValue("//*[@id='phoneTextField']", "123456")
    .setValue("//*[@id='nameTextField']", "Test")
    .setValue("//*[@id='amountTextField']", "10")
    .setValue("//*[@id='countryTextField']", "US")
    .click("//*[@id='sendPaymentButton']")
    .click("//*[@id='Yes']")
    .click("//*[@id='logoutButton']")
    .end()
    .catch(function (err) {
        console.log(err);
    });
  }
 
main();





Prerequisites

There are a few things you need to do first before you can start running Appium tests using javascript and Node.js.

  1. Install the latest Node.js.
  2. Install webdriver node bindings:

    npm install --save webdriverio
  3. Upload your App and get your cloud access key.

    Before you proceed with fetching the sample tests, you will have to do two more things, very simple but important ones:

    1. Upload your app to your project
    2. Fetch your access key


Let's make this quick and easy

Now that you are all set, you can start your testing.

  1. Find the sample test in our git repository.
  2. Fork the repository.
  3. Edit the test and hit Run. Enjoy!


  • No labels