Boilerplate project to run Appium tests together with WebdriverIO and BDD with cucumber for:
- iOS/Android Native Apps
- iOS/Android Hybrid Apps
This project was based on webdriverio/appium-boilerplate
This boilerplate uses the WebdriverIO native demo app which, the version of the app used in this boilerplate is in the apps folder, other versions can be found at this link release. Before running tests, please replace the App in the
./appsdirectory with your app.
- node >= 10.18.x - how to install Node
- yarn >= 1.21.x - how to install Yarn
See Installing Appium on a local machine
To setup your local machine to use an Android emulator and an iOS simulator see Setting up Android and iOS on a local machine
Install the dependencies:
$ yarn installStart the appium server:
$ appiumThe
@wdio/appium-serviceis integrated in this boilerplate so you don't need to start an Appium server yourself, WebdriverIO will do that for you.
This boilerplate uses a specific config for iOS and Android, see configs and are based on wdio.shared.conf.js.
This shared config holds all the defaults so the iOS and Android configs only need to hold the capabilities and steps that are needed for running on iOS and or Android.
Since we do not have Appium installed as part of this package, this has been configured to use the global Appium installation. This is configured in wdio.shared.conf.js
appium: {
command : 'appium'
},
In this project the application remains open during the execution of one suite and another, if a new session is necessary or restart the application during execution, change these settings in the file
config.capabilities = [
{
'appium:noReset': true,
'appium:fullReset': false,
'appium:dontStopAppOnReset': true,
}
To run the webview app tests you need chromedriver, it can be found here, after downloading, edit the file wdio.android.app.conf.js and add the path to the folder where the chromedriver
config.capabilities = [
{
'appium:chromedriverExecutableDir': '<PATH TO CHROME DRIVER>',
}
In the directory
./tets/featuresAndStepsPortuguese/there are features and steps with the keywords in Portuguese.
If you want to use another language in features files, you can see this doc about how can you do that.
// For Android
$ yarn android.app
// For iOS
$ yarn ios.appRun this command to generate the allure report in the directory ./test-report/allure-report:
$ yarn report:generateYou can run this command to start a server on your machine and open the allure report on the browser:
$ yarn report:openRun check lint:
$ yarn code:checkRun format lint:
$ yarn code:formatThe locator strategy for this boilerplate is to use accessibilityID's, see also the WebdriverIO docs or this newsletter on AppiumPro.
accessibilityID's make it easy to script once and run on iOS and Android because most of the apps already have some accessibilityID's.
If accessibilityID's can't be used and for example only XPATH is only available then the following setup could be used to make cross-platform selectors
const SELECTORS = {
WEB_VIEW_SCREEN: browser.isAndroid
? '*//android.webkit.WebView'
: '*//XCUIElementTypeWebView',
};The same applies when we have the same identifier in both applications, but the behavior is different, so we can apply cross-platform functions
if (driver.isIOS) {
return expect(cardText).contain(expectedText);
}
return expectedText
.split(' ')
.forEach((word) => expect(cardText).contain(word));
}, This boilerplate now also provides a setup for testing with the Real Device Cloud (RDC) of Sauce Labs. Please check the SauceLabs-folder to see the setup for iOS and Android.
With the latest version of WebdriverIO (
5.4.13and higher) the iOS and Android config holds:
Make sure you install the latest version of the @wdio/sauce-service with
$ npm install --save-dev @wdio/sauce-serviceand add services: ['sauce'], to the config. If no region is provided it will automatically default to the US-RDC cloud.
If you provide region: 'us' or region: 'eu' it will connect to the US or the EU RDC cloud
There are 2 scripts that can be used, see the package.json, to execute the tests in the cloud:
// For iOS
$ yarn ios.sauce.rdc.app
// For Android
$ yarn android.sauce.rdc.app