09.Running a Test in Mobile Devices
- 01.About Pitalium
- 02.Environment Setup
- 03.Writing Test Code
- 04.Running a Test
- 05.Taking a Screenshot of a Specific DOM Element
- 06.Taking a Screenshot of a DOM Element with Scroll
- 07.Excluding Elements from Comparison Targets
- 08.Redefining of Correct Images
- 09.Running a Test in Mobile Devices
- 10.Pitalium Explorer
Introduction
In recent years, as smart phones become common, testing web applications on mobiles grows increasingly important. In this chapter, you learn how to set up environment of testing on Android mobiles (in this tutorial, we use Android 4.4.4 Xperia Z3) using Appium .
What is Appium
Appium is an open source software for testing on mobiles such as Android mobiles and iPhone through Selenium WebDriver interface. Pitalium use Appium for testing on mobiles.
Preparation
In this tutorial, you use the same machine as that of Selenium Grid.
Install Android SDK
To use the Android debug tool, you must install and setup Android SDK.
- Download android-sdk_rXX-windows.zip from here.
- Move the zip file you downloaded to a suitable folder like C:\opt\android.
- Execute C:\opt\android\SDK Manager.exe and install the following packages.
・Android SDK Platform-tools
・Android SDK Build-tools (the newest number) - Add C:\opt\android\platform-tools to a path environment.
Install Node.js
Since Appium runs on Node.js, install Node.js.
Install Git
To install Appium, you need to download Git.
Add Environment Variables
Add Android and Java location to environment variables as follows:
Name of an environment variable | value example |
---|---|
ANDROID_HOME | C:\opt\android |
JAVA_HOME | C:\Program Files\Java\jdk1.8.0_11 |
Prepare Appium
Install Appium
Execute the following command in the command prompt to install the newest Appium.
Check running Appium
You can check whether Appium is executable by the following command.
A result is as follows:
✔ ANDROID_HOME is set to "C:\opt\android"
✔ JAVA_HOME is set to "C:\Program Files\Java\jdk1.8.0_11."
✔ ADB exists at C:\opt\android\platform-tools\adb.exe
✔ Android exists at C:\opt\android\tools\android.bat
✔ Emulator exists at C:\opt\android\tools\emulator.exe
✔ Android Checks were successful.
✔ All Checks were successful
Register to Selenium Grid Hub Server
(The following tutorial needs Android 4.2 or more. See here if you want to use under Android 4.1.)
To use Appium through Selenium Grid, register an Appium node to Selenium Grid Hub as in Environment Setup(Selenium Grid).
Create a json file like the following. See also here. Let the file be C:\opt\appium\nodeConfig.json.
Note that you can easily identify devices in Grid Hub Console by setting version value to an easy-to-understand name.
"capabilities": [
{
"platform": "ANDROID",
"browserName": "chrome",
"version": "4.4.4 Xperia Z3",
"platformName": "Android",
"platformVersion": "4.4.4",
"deviceName": "Xperia Z3",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"configuration": {
"cleanUpCycle": 2000,
"timeout": 30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"host": "127.0.0.1",
"port": 4723,
"maxSession": 1,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "localhost"
}
}
Note that if the machine Appium runs on is different from the one Selenium Grid Hub runs, set the "hubHost" value to an address of Selenium Grid Hub Server.
Execute the following command to run Appium. Note that you should specify an absolute path of nodeConfig.json.
Run a test
Connect an Android device to PC where Appium runs. Enable USB debug mode of device settings.
Using the following capabilities.json, run a Pitalium test on the mobile.
{
"platform": "ANDROID",
"browserName": "chrome",
"version": "4.4.4 Xperia Z3",
"platformName": "Android",
"platformVersion": "4.4.4",
"deviceName": "Xperia Z3"
}
]
Next Step ⇒ 10.Pitalium Explorer