You are on page 1of 10

Appium By Nagesh

APPIUM
Appium is an open source test automation framework for use with
native, hybrid and mobile web apps.
It drives iOS and Android apps using the WebDriver protocol.

Appium is "cross-platform": it allows you to write tests against multiple


platforms (iOS, Android), using the same API. This enables code reuse between
iOS and Android test suites.

1. Download Appiumexe and install it


(https://bitbucket.org/appium/appium.app/downloads/)
2. Download selenium-server-standalone-3.0.1& Selenium-Java client jar files
(http://docs.seleniumhq.org/download/)
3. Download Appium java client jar file (http://appium.io/downloads.html)
4. Download Eclipse (http://www.eclipse.org/downloads/)
5. Go to eclipse and Create the Project in eclipse with all the jars
a. Selenium server
b. selenium java client
c. appium jar(java clinet jar)
6. Download Android SDK zip file (android-sdk_r24.4.1-
windows.zip)(http://developer.android.com/sdk/index.html)
7. Environment variables
a. ANDROID_HOME: E:\Android SDK
b. JAVA_HOME : C:\Program Files\Java\jdk1.8.0_05
c. path: E:\Android SDK\tools; E:\Android SDK\platform-
tools;C:\Program Files\Java\jdk1.8.0_05\bin;
Appium By Nagesh

8.

9. Do the below setting in Mobile


1.Goto Developer options in settings (check the check box for
stayawake,USB debugging, Allow MockLocation)
2. Connect mobile as camera or file transfer
3. Go to command prompt and check whether the mobile
connected r not (type the command : "adb devices"
Note: If the device number is not displaying in commnad prompt then
install PDANet+ from the site (http://pdanet.co/a/). While installing
PDAnet+, phone should connected to system
10.Implement Script with TestNG
11.Update the phone and app information in the script
12.Double click on appium to open
13.Go to Android settings and update the phone information
14.Go to eclipse and Implement Script with TestNG
15.Connect Mobile to the System
16.Upda+te the ipadress of appium in the script
17.UI Automator to locate elements
18.Eclipse with Android (Optional)
Appium By Nagesh

Appium Setup

Step1: Add android plugin to Eclipse

1. How to add Android plugin to eclipse

To add the ADT plugin to Eclipse:


2. Start Eclipse, then select Help > Install New Software.
3. Click Add, in the top-right corner.
4. In the Add Repository dialog that appears, enter "ADT Plugin" for
the Name and the following URL for the Location:

https://dl-ssl.google.com/android/eclipse/

Note: The Android Developer Tools update site requires a secure connection.
Make sure the update site URL you enter starts with HTTPS.
5. Click OK.
6. In the Available Software dialog, select the checkbox next to Developer
Tools and click Next.
7. In the next window, you'll see a list of the tools to be downloaded.
Click Next.
8. Read and accept the license agreements, then click Finish.
If you get a security warning saying that the authenticity or validity of the
software can't be established, click OK.
9. When the installation completes, restart Eclipse.

Q) How to get the App Package & App Activity details for any Device..? ( I
mean for any new device)
10.Note: Make sure that you have connected your device to the system..!
Otherwise we can’t take the App Package & App Activity.
Appium By Nagesh

11.Open the command prompt  Type the following command to get the App
Package & App Activity.

12.
13.It will display as below:
Appium By Nagesh

14.

15.Copy the content and paste it any word pad / Edit Plus ..etc
16.Now search with the word “CurrentFocus”.
17.Here we can see the APP Package &App Activity. Copy it and paste it in the
excel sheet.

Note: The system IP address needs to be provided in RemoteWebdriver


Command and appium settings
Appium By Nagesh

package com.example.android.supportv13;

import static org.junit.Assert.*;

import java.net.URL;

import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class MobileWebApp {


public WebDriver driver;

@Before
public void setUp() throws Exception {
DesiredCapabilities dc=new DesiredCapabilities();
dc.setCapability("deviceName", "Nagesh");
dc.setCapability("platformVersion", "4.4.4");
dc.setCapability("platformName", "Android");
dc.setCapability("browserName", "Chrome");
dc.setCapability("appPackage",
"com.sec.android.app.launcher");
dc.setCapability("appActivity",
"com.android.launcher2.Launcher");
driver=new RemoteWebDriver(new
URL("http://192.168.1.13:4723/wd/hub"),dc);
}

@Test
public void test() throws Exception{
System.out.println("Started");
Thread.sleep(4000);
Appium By Nagesh

driver.get("http://gmail.com");

driver.findElement(By.id("Email")).sendKeys("testingse2");
driver.findElement(By.id("next")).click();
Thread.sleep(2000);

driver.findElement(By.id("Passwd")).sendKeys("selenium");
driver.findElement(By.id("signIn")).click();
Thread.sleep(2000);
}

package com.example.android.supportv13;

import static org.junit.Assert.*;


import io.appium.java_client.AppiumDriver;

import java.net.MalformedURLException;
import java.net.URL;

import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class SamsungDevice {


public WebDriver driver;

@Before
public void setUp() throws Exception {
}
Appium By Nagesh

@Test
public void test() throws Exception {
//File f=new File("D:\\Whats app\\WhatsApp.apk");
DesiredCapabilities dc=new DesiredCapabilities();
//dc.setCapability(CapabilityType.BROWSER_NAME,
"firefox");
dc.setCapability("deviceName", "Nagesh");
dc.setCapability("platformVersion", "4.4.4");
dc.setCapability("platformName", "Android");
//dc.setCapability("browserName", "Chrome");
//dc.setCapability("f", f.getAbsolutePath());

dc.setCapability("appPackage",
"com.sec.android.app.launcher");
dc.setCapability("appActivity",
"com.android.launcher2.Launcher");
driver=new RemoteWebDriver(new
URL("http://192.168.1.4:4723/wd/hub"),dc);

System.out.println("Started");
Thread.sleep(4000);

//driver.findElement(By.xpath("//android.widget.TextView[
@index='0']")).click();

driver.findElement(By.xpath("//android.widget.TextView[@
text='Phone']")).click();
//driver.quit();

driver.findElement(By.id("com.android.contacts:id/nine")).c
lick();
Appium By Nagesh

driver.findElement(By.id("com.android.contacts:id/eight")).
click();

driver.findElement(By.id("com.android.contacts:id/four")).cl
ick();

driver.findElement(By.id("com.android.contacts:id/eight")).
click();

driver.findElement(By.id("com.android.contacts:id/seven")).
click();

driver.findElement(By.id("com.android.contacts:id/three")).
click();

driver.findElement(By.id("com.android.contacts:id/four")).cl
ick();

driver.findElement(By.id("com.android.contacts:id/five")).cli
ck();

driver.findElement(By.id("com.android.contacts:id/nine")).c
lick();

driver.findElement(By.id("com.android.contacts:id/five")).cli
ck();

driver.findElement(By.id("com.android.contacts:id/five")).cli
ck();

driver.findElement(By.id("com.android.contacts:id/callbutto
n")).click();
Thread.sleep(3000);
Appium By Nagesh

driver.findElement(By.xpath("//android.widget.Button[@te
xt='End call']")).click();

IE Xpath:

http://functionaltestautomation.blogspot.in/2008/12/xpath-
in-internet-explorer.html

You might also like