Ready to use yadda BBD test framework with appium and chai
- added ability to run with device logging disabled (set
deviceLogs: true
to switch log back on in device configuration)
- to use async and await ensure you have babel-polyfill
- added log the this available in steps
- added global logging availability
- updated example project and readme
npm i ya-done-appium --save
The aim of this package is to build a simple configuration for 'yadda' to enable QA test engineers to productively build test projects for mobile projects using JavaScript.
ya-done configures 'yadda' with chai with 'appium'. 'yadda' has been created with two context properties. 'appium' can be accessed via the property 'driver' additionally a property of 'ctx', type object, has been added to allow the passing of data between steps.
For more information please look at the example project.
package.json script
{
"scripts": {
"test": "mocha index.js --require babel-polyfill --compilers js:babel-register inlineAssets=true --timeout 60000"
}
}
install and run the project
npm i
npm test
sample project structure
│ index.js
└───steps
│ └───given
│ └───when
│ └───then
└───features
│ sample.feature
SAMPLE FEATURE
Feature: Sample feature
Scenario: Sample
Given an element is displayed on the device
When another element is clicked
Then a different element is displayed
STEPS LIBRARY
import { yaddaLibrary } from 'ya-done-appium';
const runTests = () => yaddaLibrary()
.given(
'an element is displayed on the device',
async function anElementIsDisplayed() {
const clickableElement = await this.driver.elementById(/*your element id*/);
this.log('clickableElement', clickableElement);
await clickableElement.click();
// assert properly this element is here
assert.ok(true, this.step);
}
)
.when(
'another element is clicked',
async function anotherElementIsClicked() {
const clickableElement = await this.driver.elementById(/*your element id*/);
this.log('clickableElement', clickableElement);
await clickableElement.click();
assert.ok(true, this.step);
}
)
.then(
'a different element is displayed',
async function anotherElementIsDisplayed() {
await this.driver.sleep(3000);
const logout = await this.driver.elementById(/*your element id*/);
this.log('clickableElement', clickableElement);
// assert properly this element is here
assert.ok(true, this.step);
}
);
export default runTests();
local ios configuration
import { yaddaCore } from 'ya-done-appium';
import steps from './steps';
// device to test on
const localIos = {
platformName: 'iOs',
platformVersion: '11.0',
deviceName: 'iPhone 7 Plus',
app: // Add local ios ipa here
deviceLogs: true // This will print out the device configuration after booting device
};
// no server is required for local (exclude or 'undefined' for localhost)
const server = undefined;
// enable verbose logging in the console (this is not required)
const verboseLogging = true;
yaddaCore(steps, localIos, server, verboseLogging);
local android configuration
import { yaddaCore } from 'ya-done-appium';
import steps from './steps';
// device to test on
const localAndroid = {
platformName: 'Android',
platformVersion: '7.0',
deviceName: 'device',
app: // Add local Android APK path here
deviceLogs: true // This will print out the device configuration after booting device
};
// no server is required for local (exclude or 'undefined' for localhost)
const server = undefined;
// enable verbose logging in the console (this is not required)
const verboseLogging = true;
yaddaCore(steps, localAndroid, server, verboseLogging);
saucelabs ios configuration
import { yaddaCore } from 'ya-done-appium';
import steps from './steps';
// device to test on
const remoteIos = {
platformName: 'iOs',
platformVersion: '11.0',
deviceName: 'iPhone 7 Plus',
app: `sauce-storage:${your-ipa}`,
deviceLogs: true // This will print out the device configuration after booting device
};
// enable verbose logging in the console
const verboseLogging = true;
// server config saucelabs as example
const server = {
host: 'ondemand.saucelabs.com',
port: 80,
auth: `${SAUCELABS_USER}:${SAUCELABS_AUTH}`,
};
yaddaCore(steps, remoteIos, server, verboseLogging);
saucelabs android configuration
import { yaddaCore } from 'ya-done-appium';
import steps from './steps';
// device to test on
const remoteAndroid = {
'appium-version': '1.6.5',
platformName: 'Android',
platformVersion: '6.0',
deviceName: 'Android Emulator',
app: `sauce-storage:${your-apk}`,
deviceLogs: true // This will print out the device configuration after booting device
};
// enable verbose logging in the console
const verboseLogging = true;
// server config saucelabs as example
const server = {
host: 'ondemand.saucelabs.com',
port: 80,
auth: `${SAUCELABS_USER}:${SAUCELABS_AUTH}`,
};
yaddaCore(steps, remoteAndroid, server, verboseLogging);