wd-android
A wrapper for wd
node package optimized for Android to work with appium.io.
Install
npm install wd-android
Prerequisites
You need to install Appium.
You can install with npm:
npm install -g appium
or download it from appium website.
and then check if your ANDROID_HOME
and JAVA_HOME
are correctly.
You can achieve this by running:
$ appium-doctor --android
Running Android Checks
✔ ANDROID_HOME is set to "/path/to/android/sdk"
✔ JAVA_HOME is set to "/path/to/java/sdk"
✔ ADB exists at /sdk/platform-tools/adb
✔ Android exists at /sdk/tools/android
✔ Emulator exists at /sdk/tools/emulator
✔ Android Checks were successful.
✔ All Checks were successful
If you're usigin Android Studio and you have installed the sdk in Android Studio folder, may you need to run:
$ ln -s /path/to/Android Studio.app /path/to/AndroidStudioApp
$ export ANDROID_HOME=/path/to/AndroidStudioApp/sdk
Cause Appium doesn't work with spaces in ANDROID_HOME
or JAVA_HOME
paths.
Before start
Before launch your script with wd-android
you need to run the appium server.
It's quite simple:
$ appium
Usage
How to instantiate:
var wd = WdAndroid = ; var wdAndroid = wd; var driver = wdAndroid; driver;driver ;
Api
More friendly methods to referer to Android Elements than by XPath.
// driver.elementByXPath('//android.widget.FrameLayout')driver; // driver.elementByXPath('//android.widget.LinearLayout')driver; // driver.elementByXPath('//android.widget.ListView')driver; // driver.elementByXPath('//android.view.support.v4.ViewPager)driver; // driver.elementByXPath('//android.webkit.WebView)driver;
Simple Id
Pass the default package as secondo arguments in wd-android constructor to find element by their simple ids.
// wd waydriver; // wd-android wayvar wdAndroid = wd 'com.example.app';......driver
Sub-elements Reference
Access the sub-elements by passing parent element id.
N.B.: The original wd module hasn't this feature.
And yes, you can use the simple elements ids.
driver // with simple id ;
Alerts
Access the alert dialog showed without pain.
driver text shouldbecome text shouldbecome;
Mobile Gestures
Built in methods to perform mobile gestures.
// perform swipe from 90% of the screen width to 10% driver;
Mobile Gestures for specific element
// swipe elementdriver ; // tap element driver ;
Should integration
// wd waydriver ; // wd-android waydriver
Mocha Integration
var path = wd = WdAndroid = ; var appiumServer = host: 'localhost' port: 4723; var android19 = browserName: '' 'appium-version': '1.2.2' platformName: 'Android' platformVersion: '4.4.2' deviceName: 'Android Emulator' app: undefined; var androidDebugApp = '../path/to/your/apk'; ;