Javascript
Continuous Testing Cloud lets you execute Appium tests on remotely located devices. This page discusses how to prepare and execute Appium tests using JavaScript and Node.js, as well as use your existing Appium tests written in JavaScript.
Use of our sample tests in our git repository by cloning them, or use the sample tests.
Replace <server> with the appropriate URL.
- Public Continuous Testing Cloud - https://cloud.seetest.io/wd/hub/.
- Dedicated Continuous Testing Cloud environment - Your own domain. For example: https://company.experitest.com/wd/hub/
- On-premises Continuous Testing Cloud environment - Your designated URL. For example: https://company.com/wd/hub
Android App Testing using Javascript Expand source
"use strict";
var webdriverio = require('webdriverio');
function main() {
let options = {
host: '<server>',
protocol: 'https',
port: 443,
path: '',
desiredCapabilities: {
accessKey: "<ACCESS_KEY>",
platformName: 'android',
//udid: "<deviceid>", 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 Expand source
"use strict";
var webdriverio = require('webdriverio');
function main() {
let options = {
host: 'server',
protocol: 'https',
port: 443,
path: '',
desiredCapabilities: {
accessKey: "<ACCESS_KEY>",
platformName: 'ios',
//udid: "<deviceid>", 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 Expand source
"use strict";
var webdriverio = require('webdriverio');
function main() {
let options = {
host: '<server>',
protocol: 'https',
port: 443,
path: '',
desiredCapabilities: {
accessKey: "<ACCESS_KEY>",
platformName: 'android',
browserName: 'chrome',
//udid: "<deviceid>", 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 Expand source
"use strict";
var webdriverio = require('webdriverio');
function main() {
let options = {
host: '<server>',
protocol: 'https',
port: 443,
path: '',
desiredCapabilities: {
accessKey: "<ACCESS_KEY>",
platformName: 'ios',
//udid: "<deviceid>", 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
-
Latest Node.js.
-
webdriver node bindings:
npm install --save webdriverio
-
Applicaiton uploaded and cloud access key obtained.
warningTo proceed with fetching the sample tests:
Getting Started
-
Find the sample test in the git repository.
-
Clone the repository.
-
Edit the test, then run it.
-