Você está na página 1de 29

Appium Java

By: Jorge Avila


Agenda

● What is Appium?
● Appium Concepts
● Advantages / Disadvantages
● Architecture
● Setup Dev Environment
● Setup Project
● Demo
○ Creating a simple test with Native App
What is Appium?

Appium is a Mobile web, Native and Hybrid Software Application test automation tool
developed by Sauce Labs

it is an open source software automation tool which is useful to automate Android and iOS
platform apps
Appium Concepts
● Client/Server Architecture
○ Appium is at its heart a webserver that exposes a REST API
● Session
○ Automation is always performed in the context of a session. Clients initiate a session with a server
in ways specific to each library, but they all end up sending a POST /session request to the server,
with a JSON object called the 'desired capabilities' object
● Desired Capabilities
○ 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
● Appium Server
○ Appium is a server written in Node.js. It can be built and installed from source or installed directly
from NPM
● Appium Client
○ There are client libraries (in Java, Ruby, Python, PHP, JavaScript, and C#) which support Appium's
extensions to the WebDriver protocol
● Appium Desktop
○ There is a GUI wrapper around the Appium server that can be downloaded for any platform
Appium Philosophy

1. You shouldn't have to recompile your app or modify it in any way in order to automate it.
2. You shouldn't be locked into a specific language or framework to write and run your tests.
3. A mobile automation framework shouldn't reinvent the wheel when it comes to
automation APIs.
4. A mobile automation framework should be open source, in spirit and practice as well as in
name!
Advantages

● Cross platform: Android & iOS: we can test Native, Hybrid and Web app
● Allows you to communicate with other apps, e.g. Whatsapp, (Majority of tools does not
support this)
● No pre-compilation of your app.
● Any WebDriver compatible language is supported: Java, Objective C, Ruby, PHP, C# we
just need language specific libraries to work on.
Disadvantages

● No Support for android API level < 17


● Script execution is very slow in iOS Platform & Android Virtual Devices
● No Parallel execution
Appium Architecture

● Appium works as a Client / Server architecture


● Whenever the client sends a request the server will create a session and it will send back
session ID to the client so that the future communications between client and server will
happen with this session ID only
● Q: How come the server will identify the session it needs to create?
● A: Usually the client has desired capabilities which we need to pass using with the session
will be created, DC contains application name, platform version, package name, activity
name.
● Desired Capabilities are sent by the Client to Server via JSON Objects by requesting the
automation session we need.
Appium Architecture
Setup Environment
Setup Environment

Pre-requisites

● Install Java
● Eclipse / Intellij
● Maven plugin for Eclipse / Intellij
● TestNG plugin for Eclipse / Intellij
● Selenium r
● Nodejs

Android Tools

● Android Studio
● Appium Server/Appium Desktop
● Appium Client Library
Setup Environment

Start installing with default configuration:

● Java
● Android Studio
● NodeJS
● Intellij IDEA
● Appium Server

For Maven, unzip the downloaded folder and copy it to “c:\apache-maven-3.6.1\” because this
tool does not have installer exe.
Setup Environment
Environment Variables: Set the HOME for each tool
Setup Environment
Environment Variables: Set the bin folder for each tool using the home folder
Setup Environment
Install SDK Tools for android:
Setup Environment
Setup Environment
Create an Android Virtual Device: Choose Device definition
Setup Environment
Create an Android Virtual Device: Choose System
Setup Environment
Create an Android Virtual Device: Verify Configuration
Setup IDE
Create a Maven Project in Intellij IDEA:
Finishing Environment Setup

Using a command line let’s install “appium-doctor”, this tool allow is inspect if everything what
we configured till this point is OK:
Finishing Environment Setup
Once the appium-doctor is installed, let’s execute the command “appium-doctor” in the
command line
Appium Desired Capabilities

Desired Capabilities are keys and values encoded in a JSON object, sent by Appium clients to
the server when a new automation session is requested. They tell the Appium drivers all kinds of
important things about how you want your test to work

http://appium.io/docs/en/writing-running-appium/caps/index.html
Starting to Automate

Once everything is configured we have to continue with following steps:

● Start Appium desktop server


● Start Created Android virtual device
● Open the created Java Project in Intellij IDEA
Setup POM.xml

Setup this file with all the


dependencies for: <dependencies>
<dependency>
<groupId>io.appium</groupId>
● Appium <artifactId>java-client</artifactId>
<version>7.0.0</version>
● TestNG </dependency>
● Selenium <dependency>
<groupId>org.testng</groupId>
● others… <artifactId>testng</artifactId>
○ cucumber <version>6.14.3</version>
○ ... <scope>test</scope>
</dependency>
</dependencies>
Inspecting Elements - Appium
Inspecting Elements - Appium
Inspecting Elements - UI Automator Viewer
DEMO

Você também pode gostar