SlideShare a Scribd company logo
1 of 5
Download to read offline
APPIUM UNDERSTANDING DOCUMENT
What is Appium?
Appium is an open source test automation tool for mobile applications. It allows you to test all the three
types of mobile applications: native, hybrid and mobile web. It also allows you to run the automated
tests on actual devices, emulators and simulators. Today when every mobile app is made in at least two
platform iOS and Android, you for sure need a tool, which allows testing cross platform. Having two
different frameworks for the same app increases the cost of the product and time to maintain it as well.
The basic philosophy of Appium is that you should be able to reuse code between iOS and Android, and
that’s why when you see the API they are same across iOS and android. Another important thing to
highlight here is that Appium doesn’t modify your app or need you to even recompile the app. Appium
lets you choose the language you want to write your test in. It doesn’t dictate the language or
framework to be used.
Appium Architecture:-
Below is a diagram which explains how Appium works:
 Automation commands are sent in the form of JSON via HTTP requests.
 JavaScript Object Notation (JSON) is primarily used to transfer data between a server & a client
on the web
 Appium server establishes a session with the client & sends command to the target device based
on the desired capabilities the Appium has received.
 Desired capabilities are a set of keys and values (i.e., a map or hash) sent to the Appium server
to tell the server what kind of automation session we’re interested in starting up.
 With uiautomatorviewer, you can inspect the UI of an application in order to find the layout
hierarchy and view the properties of the individual UI components of an application.
Appium System Installation Guide:-
 Pre-requisites for Appium Installation :-
 Installation of JDK 1.7 or higher
 Installation of Android SDK
 Eclipse IDE of your choice
 Android Requirements :
 Install Android SDK API >=17
Step by Step Installation Guide:
 Download & Install .NET Framework 4.5 (if not installed earlier on your machine)
 Download & install JDK 7 & higher
 Set Java Home & path in the Environment Variables
 Download Eclipse
 Install TestNG from Eclipse marketplace
 Enable developer mode on your Android mobile
 Download Android SDK
 Set Android Home & path in the Environment Variables
 Open SDK Manager & update all the Android API levels which are greater than level 17
 Download & install latest Appium executable from
https://bitbucket.org/appium/appium.app/downloads/ (the current latest version is 1.3.7.2)
 Download Appium client libraries from
https://search.maven.org/#search%7Cga%7C1%7Cg%3Aio.appium%20a%3Ajava-client (Appium
java-client 2.2.0 .jar)
 Download Selenium jars from http://docs.seleniumhq.org/download/ for java (latest version is
2.45.0)
 Download gson.jar for appium from
http://mvnrepository.com/artifact/com.google.code.gson/gson/2.2.4
 Download Node.js & install from https://nodejs.org/
Steps to create and run android test script:
1. Go to Appium downloaded package unzip and click on “Appium.exe”. Appium server console will be
open like below:
2. You can change IP address to the IP of your local machine. Keep the port as default i.e. 4723.
3. Click on Launch button to run Appium server you should see Appium server running window like
below
4. Launch emulator or connect device to the machine. Run adb command from command prompt to
check device is connected to your machine.
5. Below is sample code of webdriver in java for Appium in TestNg framework.
Sample Code:-
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.server.handler.interactions.touch.Flick;
import org.testng.annotations.Test;
import io.appium.java_client.InteractsWithApps;
import io.appium.java_client.SwipeElementDirection;
import io.appium.java_client.android.AndroidDriver;
public class WhatsApp {
AndroidDriver driver;
@Test
public void testWhatsApp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "D6502");
capabilities.setCapability("platformVersion", "5.0.2");
capabilities.setCapability("platformName", "Android");
File file = new File("E:AKSHAYassignmentsSelenium_WorkspaceAppium
TestapkWhatsApp.apk");
capabilities.setCapability("app", file.getAbsolutePath());
capabilities.setCapability("app-package", "com.whatsapp");
capabilities.setCapability("app-activity", ".HomeActivity");
driver = new AndroidDriver(new URL("http://10.0.1.20:4723/wd/hub"),
capabilities);
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.findElementById("com.whatsapp:id/menuitem_search").click();
WebElement text = driver.findElementByClassName("android.widget.EditText");
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
text.sendKeys("cd kitne");
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.findElementById("com.whatsapp:id/conversations_row_contact_name").click();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
for(int i=0;i<4;i++){
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.findElementById("com.whatsapp:id/entry").sendKeys("Hi Guys..");
driver.findElementById("com.whatsapp:id/send").click();
}
driver.closeApp();
}
}
The above Sample code is used to automate WhatsApp in which message is sent to a WhatsApp group
on execution of code.
Automating Gestures:-
Gestures play an important role in how your app is being used. With lot of unique gesture supported on
mobile devices, automation has its own challenge. Some of the common gestures are:
 single tap
 double tap
 flick (left or right)
 pull down to refresh
 long press
Appium handles these gestures using TouchActions api they have created. It’s more like Actions class in
Selenium. Apart from that they have also enabled JSON wire protocol server extensions. We can pass in
coordinates as parameters and specify the action we want. Sample code would look like as:
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> swipeObject = new HashMap<String, Double>();
swipeObject.put(“startX”, 0.01);
swipeObject.put(“startY”, 0.5);
swipeObject.put(“endX”, 0.9);
swipeObject.put(“endY”, 0.6);
swipeObject.put(“duration”, 3.0);
js.executeScript(“mobile: swipe”, swipeObject);
When we enter the coordinates in decimal, it actually specifies the percentage. So in above example it
means, 1% from x and 50% from y coordinates. Duration basically specifies how long it will tap and is in
seconds.
Some of the mobile methods to be used are:
 mobile: tap
 mobile: flick
 mobile: swipe
 mobile: scroll
 mobile: shake
Prefix “mobile:” allows us to route these requests to the appropriate endpoint.
TouchActions class provided by Selenium. It implements actions for touch devices and basically built
upon the Actions class.

More Related Content

What's hot

Appium: Mobile Automation Made Awesome
Appium: Mobile Automation Made AwesomeAppium: Mobile Automation Made Awesome
Appium: Mobile Automation Made Awesome
Netcetera
 
Testing Native iOS Apps with Appium
Testing Native iOS Apps with AppiumTesting Native iOS Apps with Appium
Testing Native iOS Apps with Appium
Sauce Labs
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
Sauce Labs
 

What's hot (20)

Automation Testing With Appium
Automation Testing With AppiumAutomation Testing With Appium
Automation Testing With Appium
 
BCS Selenium Workshop
BCS Selenium WorkshopBCS Selenium Workshop
BCS Selenium Workshop
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
 
Appium
AppiumAppium
Appium
 
Appium@Work at PAYBACK
Appium@Work at PAYBACKAppium@Work at PAYBACK
Appium@Work at PAYBACK
 
Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
 
Appium: Mobile Automation Made Awesome
Appium: Mobile Automation Made AwesomeAppium: Mobile Automation Made Awesome
Appium: Mobile Automation Made Awesome
 
Testing Native iOS Apps with Appium
Testing Native iOS Apps with AppiumTesting Native iOS Apps with Appium
Testing Native iOS Apps with Appium
 
Appium ppt
Appium pptAppium ppt
Appium ppt
 
Appium & Jenkins
Appium & JenkinsAppium & Jenkins
Appium & Jenkins
 
#Fame case study
#Fame case study#Fame case study
#Fame case study
 
Automated UI Testing Frameworks
Automated UI Testing FrameworksAutomated UI Testing Frameworks
Automated UI Testing Frameworks
 
Appium
AppiumAppium
Appium
 
Selenium webcrawler
Selenium webcrawlerSelenium webcrawler
Selenium webcrawler
 
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on WebinarParallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
 
Appium Meetup #2 - Mobile Web Automation Introduction
Appium Meetup #2 - Mobile Web Automation IntroductionAppium Meetup #2 - Mobile Web Automation Introduction
Appium Meetup #2 - Mobile Web Automation Introduction
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using Appium
 
Automation With Appium
Automation With AppiumAutomation With Appium
Automation With Appium
 
Future of Mobile Automation, Appium Steals it
Future of Mobile Automation, Appium Steals itFuture of Mobile Automation, Appium Steals it
Future of Mobile Automation, Appium Steals it
 

Viewers also liked

Activity based costing
Activity based costingActivity based costing
Activity based costing
amouqe
 
台南市腦性麻痺之友協會介紹
台南市腦性麻痺之友協會介紹台南市腦性麻痺之友協會介紹
台南市腦性麻痺之友協會介紹
輝 哲
 
Dieta e prevenção cvd versão slideshare
Dieta e prevenção cvd versão slideshareDieta e prevenção cvd versão slideshare
Dieta e prevenção cvd versão slideshare
nutriscience
 
01廖麗萍
01廖麗萍01廖麗萍
01廖麗萍
輝 哲
 
07陳思樺
07陳思樺07陳思樺
07陳思樺
輝 哲
 
Ludology presentation
Ludology presentationLudology presentation
Ludology presentation
D.I.T
 

Viewers also liked (20)

Testing Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid CloudTesting Your Android and iOS Apps with Appium in Testdroid Cloud
Testing Your Android and iOS Apps with Appium in Testdroid Cloud
 
Activity based costing
Activity based costingActivity based costing
Activity based costing
 
台南市腦性麻痺之友協會介紹
台南市腦性麻痺之友協會介紹台南市腦性麻痺之友協會介紹
台南市腦性麻痺之友協會介紹
 
Pepsi
PepsiPepsi
Pepsi
 
Dieta e prevenção cvd versão slideshare
Dieta e prevenção cvd versão slideshareDieta e prevenção cvd versão slideshare
Dieta e prevenção cvd versão slideshare
 
Jonas biliunas
Jonas biliunasJonas biliunas
Jonas biliunas
 
Genç Liderler
Genç LiderlerGenç Liderler
Genç Liderler
 
Positive mind set
Positive mind setPositive mind set
Positive mind set
 
01廖麗萍
01廖麗萍01廖麗萍
01廖麗萍
 
NARRAR POR ESCRITO DESDE UN PERSONAJE Ferreiro Emilia
NARRAR  POR  ESCRITO DESDE UN PERSONAJE Ferreiro Emilia NARRAR  POR  ESCRITO DESDE UN PERSONAJE Ferreiro Emilia
NARRAR POR ESCRITO DESDE UN PERSONAJE Ferreiro Emilia
 
07陳思樺
07陳思樺07陳思樺
07陳思樺
 
Occlusion
OcclusionOcclusion
Occlusion
 
Joanna masiubanska podrozni festival
Joanna masiubanska podrozni festivalJoanna masiubanska podrozni festival
Joanna masiubanska podrozni festival
 
El pèsol Negre. Número 4. Maig 2001 (2a època)
El pèsol Negre. Número 4. Maig 2001 (2a època)El pèsol Negre. Número 4. Maig 2001 (2a època)
El pèsol Negre. Número 4. Maig 2001 (2a època)
 
Ludology presentation
Ludology presentationLudology presentation
Ludology presentation
 
Old trafford
Old traffordOld trafford
Old trafford
 
المجلة السودانية لدراسات الراي العام
المجلة السودانية لدراسات الراي العامالمجلة السودانية لدراسات الراي العام
المجلة السودانية لدراسات الراي العام
 
Curriculo nacional-2016-
Curriculo nacional-2016-Curriculo nacional-2016-
Curriculo nacional-2016-
 
Pedoman pkm tahun 2015
Pedoman pkm tahun 2015Pedoman pkm tahun 2015
Pedoman pkm tahun 2015
 
Међумолекулске интеракције и водонична веза
Међумолекулске интеракције и водонична везаМеђумолекулске интеракције и водонична веза
Међумолекулске интеракције и водонична веза
 

Similar to Appium understanding document

Similar to Appium understanding document (20)

Browser_Stack_Intro
Browser_Stack_IntroBrowser_Stack_Intro
Browser_Stack_Intro
 
Next level of Appium
Next level of AppiumNext level of Appium
Next level of Appium
 
The ultimate guide to mobile app testing with appium
The ultimate guide to mobile app testing with appiumThe ultimate guide to mobile app testing with appium
The ultimate guide to mobile app testing with appium
 
Automation using Appium
Automation using AppiumAutomation using Appium
Automation using Appium
 
Selenium, Appium, and Robots!
Selenium, Appium, and Robots!Selenium, Appium, and Robots!
Selenium, Appium, and Robots!
 
Appium.pptx
Appium.pptxAppium.pptx
Appium.pptx
 
Android CI and Appium
Android CI and AppiumAndroid CI and Appium
Android CI and Appium
 
Designing an effective hybrid apps automation framework
Designing an effective hybrid apps automation frameworkDesigning an effective hybrid apps automation framework
Designing an effective hybrid apps automation framework
 
Appium Presentation
Appium Presentation Appium Presentation
Appium Presentation
 
Appium solution artizone
Appium solution   artizoneAppium solution   artizone
Appium solution artizone
 
appiumpresent-211128171811.pptx projet de presentation
appiumpresent-211128171811.pptx projet de presentationappiumpresent-211128171811.pptx projet de presentation
appiumpresent-211128171811.pptx projet de presentation
 
Android Automation Using Robotium
Android Automation Using RobotiumAndroid Automation Using Robotium
Android Automation Using Robotium
 
Decoding Appium No-Code Test Automation With HeadSpin.pdf
Decoding Appium No-Code Test Automation With HeadSpin.pdfDecoding Appium No-Code Test Automation With HeadSpin.pdf
Decoding Appium No-Code Test Automation With HeadSpin.pdf
 
Fastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsFastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS Apps
 
Sencha Touch MVC
Sencha Touch MVCSencha Touch MVC
Sencha Touch MVC
 
Building And Executing Test Cases with Appium and Various Test Frameworks.pdf
Building And Executing Test Cases with Appium and Various Test Frameworks.pdfBuilding And Executing Test Cases with Appium and Various Test Frameworks.pdf
Building And Executing Test Cases with Appium and Various Test Frameworks.pdf
 
Appium- part 1
Appium- part 1Appium- part 1
Appium- part 1
 
Mobile DevTest Dictionary
Mobile DevTest DictionaryMobile DevTest Dictionary
Mobile DevTest Dictionary
 
Setting UIAutomation free with Appium
Setting UIAutomation free with AppiumSetting UIAutomation free with Appium
Setting UIAutomation free with Appium
 
Mobile automation using Appium
Mobile automation using AppiumMobile automation using Appium
Mobile automation using Appium
 

Recently uploaded

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Appium understanding document

  • 1. APPIUM UNDERSTANDING DOCUMENT What is Appium? Appium is an open source test automation tool for mobile applications. It allows you to test all the three types of mobile applications: native, hybrid and mobile web. It also allows you to run the automated tests on actual devices, emulators and simulators. Today when every mobile app is made in at least two platform iOS and Android, you for sure need a tool, which allows testing cross platform. Having two different frameworks for the same app increases the cost of the product and time to maintain it as well. The basic philosophy of Appium is that you should be able to reuse code between iOS and Android, and that’s why when you see the API they are same across iOS and android. Another important thing to highlight here is that Appium doesn’t modify your app or need you to even recompile the app. Appium lets you choose the language you want to write your test in. It doesn’t dictate the language or framework to be used. Appium Architecture:- Below is a diagram which explains how Appium works:  Automation commands are sent in the form of JSON via HTTP requests.  JavaScript Object Notation (JSON) is primarily used to transfer data between a server & a client on the web  Appium server establishes a session with the client & sends command to the target device based on the desired capabilities the Appium has received.  Desired capabilities are a set of keys and values (i.e., a map or hash) sent to the Appium server to tell the server what kind of automation session we’re interested in starting up.  With uiautomatorviewer, you can inspect the UI of an application in order to find the layout hierarchy and view the properties of the individual UI components of an application.
  • 2. Appium System Installation Guide:-  Pre-requisites for Appium Installation :-  Installation of JDK 1.7 or higher  Installation of Android SDK  Eclipse IDE of your choice  Android Requirements :  Install Android SDK API >=17 Step by Step Installation Guide:  Download & Install .NET Framework 4.5 (if not installed earlier on your machine)  Download & install JDK 7 & higher  Set Java Home & path in the Environment Variables  Download Eclipse  Install TestNG from Eclipse marketplace  Enable developer mode on your Android mobile  Download Android SDK  Set Android Home & path in the Environment Variables  Open SDK Manager & update all the Android API levels which are greater than level 17  Download & install latest Appium executable from https://bitbucket.org/appium/appium.app/downloads/ (the current latest version is 1.3.7.2)  Download Appium client libraries from https://search.maven.org/#search%7Cga%7C1%7Cg%3Aio.appium%20a%3Ajava-client (Appium java-client 2.2.0 .jar)  Download Selenium jars from http://docs.seleniumhq.org/download/ for java (latest version is 2.45.0)  Download gson.jar for appium from http://mvnrepository.com/artifact/com.google.code.gson/gson/2.2.4  Download Node.js & install from https://nodejs.org/
  • 3. Steps to create and run android test script: 1. Go to Appium downloaded package unzip and click on “Appium.exe”. Appium server console will be open like below: 2. You can change IP address to the IP of your local machine. Keep the port as default i.e. 4723. 3. Click on Launch button to run Appium server you should see Appium server running window like below 4. Launch emulator or connect device to the machine. Run adb command from command prompt to check device is connected to your machine. 5. Below is sample code of webdriver in java for Appium in TestNg framework. Sample Code:- import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit;
  • 4. import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.server.handler.interactions.touch.Flick; import org.testng.annotations.Test; import io.appium.java_client.InteractsWithApps; import io.appium.java_client.SwipeElementDirection; import io.appium.java_client.android.AndroidDriver; public class WhatsApp { AndroidDriver driver; @Test public void testWhatsApp() throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName", "D6502"); capabilities.setCapability("platformVersion", "5.0.2"); capabilities.setCapability("platformName", "Android"); File file = new File("E:AKSHAYassignmentsSelenium_WorkspaceAppium TestapkWhatsApp.apk"); capabilities.setCapability("app", file.getAbsolutePath()); capabilities.setCapability("app-package", "com.whatsapp"); capabilities.setCapability("app-activity", ".HomeActivity"); driver = new AndroidDriver(new URL("http://10.0.1.20:4723/wd/hub"), capabilities); driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); driver.findElementById("com.whatsapp:id/menuitem_search").click(); WebElement text = driver.findElementByClassName("android.widget.EditText"); driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); text.sendKeys("cd kitne"); driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); driver.findElementById("com.whatsapp:id/conversations_row_contact_name").click(); driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); for(int i=0;i<4;i++){ driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); driver.findElementById("com.whatsapp:id/entry").sendKeys("Hi Guys.."); driver.findElementById("com.whatsapp:id/send").click(); } driver.closeApp(); } }
  • 5. The above Sample code is used to automate WhatsApp in which message is sent to a WhatsApp group on execution of code. Automating Gestures:- Gestures play an important role in how your app is being used. With lot of unique gesture supported on mobile devices, automation has its own challenge. Some of the common gestures are:  single tap  double tap  flick (left or right)  pull down to refresh  long press Appium handles these gestures using TouchActions api they have created. It’s more like Actions class in Selenium. Apart from that they have also enabled JSON wire protocol server extensions. We can pass in coordinates as parameters and specify the action we want. Sample code would look like as: JavascriptExecutor js = (JavascriptExecutor) driver; HashMap<String, Double> swipeObject = new HashMap<String, Double>(); swipeObject.put(“startX”, 0.01); swipeObject.put(“startY”, 0.5); swipeObject.put(“endX”, 0.9); swipeObject.put(“endY”, 0.6); swipeObject.put(“duration”, 3.0); js.executeScript(“mobile: swipe”, swipeObject); When we enter the coordinates in decimal, it actually specifies the percentage. So in above example it means, 1% from x and 50% from y coordinates. Duration basically specifies how long it will tap and is in seconds. Some of the mobile methods to be used are:  mobile: tap  mobile: flick  mobile: swipe  mobile: scroll  mobile: shake Prefix “mobile:” allows us to route these requests to the appropriate endpoint. TouchActions class provided by Selenium. It implements actions for touch devices and basically built upon the Actions class.