Webdriver.IO Integration - Appium
info
As the latest version of Webdriver.io client is W3C compliant, we recommend using Appium-OSS mode of execution in order to run these tests.
Native App Test
iOS test example Expand source
describe('Eribank test', () => {
it('Login test', async () => {
const username = await $('//*[@name="usernameTextField"]'); //find element
const password = await $('//*[@name="passwordTextField"]');
const loginButton = await $('//*[@name="loginButton"]');
await username.setValue('company'); //send key
await password.setValue('company');
await loginButton.click(); //click
})
})
Android test example Expand source
describe('Eribank test', () => {
it('Login test', async () => {
const username = await $('//*[@text="Username"]'); //find element
const password = await $('//*[@text="Password"]');
const loginButton = await $('//*[@text="Login"]');
await username.setValue('company'); //send key
await password.setValue('company');
await loginButton.click(); //click
})
})
For more advanced capabilities, see Capabilties in Appium Based Tests.
wdio.config.js example
exports.config = {
runner: 'local',
hostname: '<cloud-ip>',
protocol: 'https',
port: 443,
path: '/wd/hub',
specs: [
'./*.js'
],
capabilities: [{
platformName: '<platform>', // 'ios' for iOS tests, 'android' for Android tests
'appium:options': {
'udid': '<Device-Udid>', // Optional
'bundleId': 'com.experitest.ExperiBank', // for iOS
'appPackage': 'com.experitest.ExperiBank', // for Android
'app': "cloud:com.experitest.ExperiBank/.LoginActivity",
},
'digitalai:options': {
'testName': "Appium WebdriverIO native test", //Optional
'accessKey': "<AccessKey>", // Or userName, password and projectName if needed
'appiumVersion': "1.22.3",
},
}],
mochaOpts: {
ui: 'bdd',
timeout: 180000
},
Web Test
Web test example Expand source
const assert = require('assert')
describe('webdriver.io page', () => {
it('should have the right title', async () => {
await browser.url('https://digital.ai/continuous-testing')
const title = await browser.getTitle()
assert.strictEqual(title, 'Digital.ai Continuous Testing | Scalable App & Device Testing Tool')
})
})
For more advanced capabilities, see Capabilties in Appium Based Tests.
wdio.config.js example
exports.config = {
runner: 'local',
hostname: '<cloud-ip>',
protocol: 'https',
port: 443,
path: '/wd/hub',
specs: [
'./*.js'
],
capabilities: [{
platformName: '<platform>', // 'ios' for iOS tests, 'android' for Android tests
browserName': 'chrome',
'appium:options': {
'udid': '<Device-Udid>', // Optional
},
'digitalai:options': {
'testName': "Appium WebdriverIO webtest", // Optional
'accessKey': "<AccessKey>", // Or userName, password and projectName if needed
'appiumVersion': "1.22.3",
}
},
],
mochaOpts: {
ui: 'bdd',
timeout: 180000
},
}
Webdriver.io Run
To run your tests, run the applicable command in a command line window:
- Windows:
npx wdio run .\wdio.conf.js
- Mac:
npx wdio run ./wdio.conf.js