Blog
Tutorial(Pitalium: hifive regression test library) » 09.Running a Test in Mobile Devices

 09.Running a Test in Mobile Devices

Last modified by kashi on 2016/04/13, 13:54

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.

  1. Download android-sdk_rXX-windows.zip from here.
  2. Move the zip file you downloaded to a suitable folder like C:\opt\android.
  3. Execute C:\opt\android\SDK Manager.exe and install the following packages.
    ・Android SDK Platform-tools
    ・Android SDK Build-tools (the newest number)
  4. 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.

npm installl -g appium

Check running Appium

You can check whether Appium is executable by the following command.

appium-doctor

A result is as follows:

Running Android Checks
✔ 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.

appium --nodeconfig C:\opt\appium\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

See also


Copyright (C) 2012-2017 NS Solutions Corporation, All Rights Reserved.