Professional Documents
Culture Documents
Limitations OfAppium
What Is Appium?
Android
IOS
FirefoxOS
the Selenium
Java
Objective-C
JavaScript with Node.js
PHP
Python
Ruby
C#
Clojure
Perl
Also there are other advantages like no source code is needed to test app
as you can test it directly, also you can engage built in apps like camer a,
calendar
etc
in
your
test
script
if
required.
Limitations
Of
There are few limitation in appium right now.
Appium
When you will click on link, It will show you dialog to save .exe
file.
Go to C:\Program Files\Java.
There will be JDK folder with version number. Example : For me
it is "jdk1.8.0_45".
Double click on It.
Copy folder path. Example : C:\P rogram Files\Java\jdk1.8.0_45
It will set JDK bin folder path in your system environment variable.
Verify java is installed properly or not
To verify java software is installed properly or not,
variables.
Bellow given steps will show you Android SDK software download and
installation steps. My next post will show you how to
set ANDROID_HOME and Path environment variables in windows.
Go
to
this
software
web
application
> http://developer.android.com/sdk/index.html
Scroll down to bottom of page.
page
Install Intel
Hardware
Accelerated
Execution
Manager
After installation of all packages, You need to install Intel Hardware
Accelerated Execution Manager to avoid error during android virtual
device creation. Following steps will install it.
At
"E:\SDK\extras\intel\Hardware_Accelerated_Execution_Manager"
path, You will find "intelhaxm-android.exe" file.
Double click on "intelhaxm-android.exe" file to execute and install
it.
This will reduce errors and complexity during android emulator creation
and
launch
process.
That's it.
After installation of different packages and system images, You need to
set ANDROID_HOME and Path environment variables. View next post
to know how to set it.
Properly
That
means
android is
configured properly in
your system.
IDE. After installing ADT in eclipse, You can setup android project,
debug apps and build apps.
However we CAN use it to launch android emulators through eclipse to
run automation tests on it using appium. Also you can launch android
virtual devices(Emulator) direct from SDK folder -> AVD Manager.exe.
So this is optional step but still let me describe you how to do it if you
wish to launch AVD Manager from eclipse.
Download And Installing ADT plugin in eclipse
Bellow given steps will describe you how to install ADT plugin in
eclipse.
PREREQUISITES
Bellow given tools/components should be available/installed
You need to set SDK folder path after installation of ADT plugin which
enables eclipse to integrate with android development environment.
Follow the steps given bellow.
Open eclipse
Preferences.
IDE Preferences
dialog
from Windows
->
This confirms that android SDK is integrated properly with eclipse IDE
using ADT plugin.
Download
To download Microsoft .Net Framework,
Install
Install
Install
Go to THIS PAGE.
Click on Download Appium button.
file.You
will
2. Install Appium
General Settings
Go to Settings.
Check if there is any option like "Developer Option"?
Go to Settings.
Scroll down to bottom and tap on About Phone.
Scroll down bottom again on About Phone screen. You will see
option Build number.
Tap seven times on Build number option one by one. After 3 tap,
It will start showing you message like.. "You are now 2 steps away
from being a developer" as shown in bellow image.
After 7 times Build number option tap, It will show you message
"You are now a developer!" as shown in bellow image.
There will be option USB debugging with check box. Check it.
It will show you list of connected devices with your PC. If not display
any device in list that means there is some issue with device connection
or
USB
debugging
mode
is
not
enabled
properly.
Note : If face any issue in android device detecting with PC, Please
install PDANet+ for Android in your system as described in THIS
POST.
This is the way to enable developer mode and USB debugging mode in
your android device to connect it with PC in development environment.
Now you can run native apps automation test in physical devices using
appium and selenium webdriver. We will learn it in my upcoming posts.
Next post will show you how to locate different elements of android
native app using uiautomatorviewer.
We will use default and simple calculator app of android phone to learn
how to inspect its's UI elements using UI Automator Viewer tool.
Follow the steps given bellow.
As
you
can
see
in
above
image,
Parent
class android.widget.LinearLayout class with index = 1 has buttons 4,
5, 6 and X. So we can locate that specific row by it's class index. Child
element is member of class android.widget.Button with index = 1. So
we can format XPath using parent and child class hierarchy as bellow.
xpath("//android.widget.LinearLayout[@index='1']/android.widget.Button[@index
='1']")
Supposing element has content-desc which is unique then you can use it
to create XPath. Example : DELETE button has unique content-desc =
delete. So we can write XPath for delete button using it as bellow.
xpath("//android.widget.Button[@content-desc='delete']")
If you see in above image, button Equals has text value "=". So we can
locate it by name using bellow given syntax.
By.name("=")
List<WebElement>calcButtons =
driver.findElements(By.xpath("//android.widget.Button"));
Above given syntax will store list of all buttons in list calcButtons with
bellow given array list index ids. Bellow given table illustrate array
index ids for different buttons of calculator application.
Button
Array index ID
DELETE
(divide)
Button
Array index ID
(multiply)
10
11
(minus)
12
.(point)
13
14
=(equals)
15
+(plus)
16
So now we can access required button using it's index which is stored in
list calcButtons. Means if you wants to tap on button 5 then you can use
bellow given syntax.
calcButtons.get(6).click();
So all these are different ways to locate android software app elements.
We will use all these element locator methods practically in our test
scripts which I will publish in upcoming steps.
This way you can get any android software application's package name
and launcher activity name easily. We have to use both these parameters
in test script.
New
Project
In
Eclipse
Before creating new project In eclipse, You must be aware about how to
download Eclipse IDE, How to create workspace for project, Creating
new project and package In eclipse and adding jar files In your project's
build path. I have already described all these thing In THIS POST so I
will not repeat It here.
Start Eclipse IDE. It will ask you to set workspace If you are using
It first time.
Set workspace.
Create new project(With your desired name. For me It Is
MavenProject1) In eclipse with package name Android.
Install TestNG : I hope testng is already installed in your eclipse.
View THIS POST to know how to install testng in eclipse.
You can download jar files for selenium webdriver from THIS
PAGE. View THIS POST for more detail.
You can download latest version of appium client libraries(javaclient-x.x.x.jar where x.x.x is current latest version of
jar) from THIS PAGE. Click on Java link, It will take you on jar
file download page.
It
will
start
Download
Latest
Jar
File
Of google-gson
You also need google-gson's latest jar file. Current latest version Is
2.3.1. You will find google-gson download link on THIS PAGE.
That's it..
Using maven? :
If you are using maven project management tool with eclipse then no
need to add above jar files in project's build path but you have to add
Selenium WebDriver, Appium Java Client Libraries and
gson dependencies in pom.xml file.
Current latest dependencies for selenium, appium java client and gson
are as bellow. It may change in future so update accordingly.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.47.1</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
This is all about appium project configuration in eclipse for maven and
non maven users.
Note : You can consider appium node server is started properly once it
shows
log
as
shown
in
above
image.
1.
2.
3.
4.
Now create bellow given test class under Android package of your
appium project. Usage of each code syntax is given in script itself.
SimpleAndroidCalcTest.java
package Android;
importjava.net.MalformedURLException;
import java.net.URL;
importjava.util.concurrent.TimeUnit;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.remote.CapabilityType;
importorg.openqa.selenium.remote.DesiredCapabilities;
importorg.openqa.selenium.remote.RemoteWebDriver;
importorg.testng.annotations.AfterTest;
importorg.testng.annotations.BeforeTest;
importorg.testng.annotations.Test;
public class SimpleAndroidCalcTest {
WebDriver driver;
@BeforeTest
public void setUp() throws MalformedURLException {
// Created object of DesiredCapabilities class.
DesiredCapabilities capabilities = new DesiredCapabilities();
// Set android deviceName desired capability. Set your device name.
capabilities.setCapability("deviceName", "ZX1B32FFXF");
// Set BROWSER_NAME desired capability. It's Android in our case here.
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
// Set android VERSION desired capability. Set your mobile device's OS
version.
capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
// Set android platformName desired capability. It's Android in our case
here.
capabilities.setCapability("platformName", "Android");
// Set android appPackage desired capability. It is
// com.android.calculator2 for calculator application.
// Set your application's appPackage if you are using any other app.
capabilities.setCapability("appPackage", "com.android.calculator2");
// Set android appActivity desired capability. It is
// com.android.calculator2.Calculator for calculator application.
// Set your application's appPackage if you are using any other app.
capabilities.setCapability("appActivity",
"com.android.calculator2.Calculator");
// Created object of RemoteWebDriver will all set capabilities.
// Set appium server address and port number in URL string.
// It will launch calculator app in android device.
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
@Test
public void Sum() {
// Click on DELETE/CLR button to clear result text box before running test.
driver.findElements(By.xpath("//android.widget.Button")).get(0).click();
// Click on number 2 button.
driver.findElement(By.name("2")).click();
// Click on + button.
driver.findElement(By.name("+")).click();
// Click on number 5 button.
driver.findElement(By.name("5")).click();
// Click on = button.
driver.findElement(By.name("=")).click();
// Get result from result text box.
String result =
driver.findElement(By.className("android.widget.EditText")).getText();
System.out.println("Number sum result is : " + result);
}
@AfterTest
public void End() {
driver.quit();
}
}
Note : Before running above script using testng, Please make sure your
android device is connected with PC with USB debugging mode enabled
and Appiun node server is launched and started.
4. Running Appium Test Script
I hope you already know how to run software test script using testng
(VIEW EXAMPLE). Run above test script and view your android
phone screen. It will
This way, We have executed very simple test script in android mobile
device. If you have noticed in above example test script, We have used
only name locator. We will use all different element locators (Which are
described in THIS POST) in upcoming examples.
Note : In Target drop down, You need to select that API level for which
you have installed system images during SDK installation. I have
installed Android 5.1.1 - API Level 22 so selected it here. Also do not
put space in AVD Name textbox.
Same way you can create any other size device emulators too as per your
system images installation for different Android API levels.
Start AVD Emulator
Note : Please make sure you have minimum 2 GB RAM in your system.
4 GB RAM is recommended. AVD Emulator uses large amount of
memory. So please close all non-required software applications before
starting it.
To start Emulator
Wait for a while. Emulator screen will looks like bellow after few
minutes. Be patient.
This way you can create and launch emulator for android device in
windows system. We will use this emulator to automate different
android apps in my upcoming posts.
Verify Emulator Detected
You can detect emulator from command prompt using command adb
devices as shown in bellow image.
Navigate
to platform-tools folder
in
command
prompt. In platform-tools folder, Press
keyboard's CTRL+Shift+Mouse Right Click. It will open right
Run adb
prompt.
install
com.intelloware.apkinfo.apk in
command
It
will
show
Go to Settings of Emulator.
Tap on Apps.
When app get uninstalled, It will show you message Success. That
means app is uninstalled from your emulator. You can verify it in
your emulator.
This way you can install and uninstall any app in your emulator.