Professional Documents
Culture Documents
Mobile App Test Automation With APPIUM
Mobile App Test Automation With APPIUM
With Appium
May, 2019
Agenda
01 Install Appium
05 Automating Mobility
Install Appium
Step 1: Java Installation and Setup
With Appium, you would need to write automation test scripts that interact with the
screens and controls (buttons, text boxes etc) in your mobile app and perform actions
on them. We would use Java to write these automation scripts.
4. Navigate to the folder where you had downloaded JDK. Double click on
the exe file to start the installation process. The installation process would now begin.
Click on Next button on the Setup screen
Install Appium
Step 1.1: Download and Install latest version of Java 8 (JDK)
5. On the Custom Setup screen, leave the installation folder as it is and click on
Next button.
Install Appium
Step 1.1: Download and Install latest version of Java 8 (JDK)
6. Wait for few seconds for Java to install some files. After that, it will ask you to specify
the destination folder of JRE. Leave the default location as it is and click on Next button
Install Appium
Step 1.1: Download and Install latest version of Java 8 (JDK)
8. Once the installation is completed, you would see the window as shown in the
below screenshot. Click on Close button to close the window
Install Appium
Step 1.1: Download and Install latest version of Java 8 (JDK)
9. To verify that the installation is successful, open Java folder in Program files.
You would see that new JRE & JDK folders with the latest version numbers have
been created. Don‟t worry if you see previous versions of JRE or JDK folders in there.
Multiple versions of JDKs & JREs can co-exist.
Install Appium
Step 1.2: Setup Java Environment Variables
1. Now open the JDK folder. If you have multiple JDK folders, then open the one
which represents the latest version, and copy the folder location. As per the below
screenshot, we are copying this folder
location – C:\Program Files\Java\jdk1.8.0_171
Install Appium
Step 1.2: Setup Java Environment Variables
2. You have to now open environment variables window in your machine. To do this,
click on Start menu. Then right click on Computer and
select Properties option
Install Appium
Step 1.2: Setup Java Environment Variables
7. Click on OK button. You will see that JAVA_HOME variable has now been added
in System Variables.
If you already have JAVA_HOME previously set, then you can click on Edit button to
modify its value. You have now successfully setup JAVA_HOME variable. Let us now
check how to setup the Path variable.
Install Appium
Step 1.2: Setup Java Environment Variables
In the Environment variables window, check that there is a variable called Path under
System variables. Please note that Path is an existing variable and we would edit it to
add the bin folder location
Install Appium
Step 1.2: Setup Java Environment Variables
9. Select the Path variable and click on Edit button. Path variable window would
be opened. Move over to the end of Variable value text field. There would be already
some value there. Put a semi-colon (;) at the end and then add the JDK folder
location – %JAVA_HOME%\bin, as shown below (Semi-colon is a delimiter which is
used to differentiate between different values in Path variable)
Install Appium
Step 1.2: Setup Java Environment Variables
10. Click on Ok button. bin folder location would now have been added in
the Path variable. Close the Environment variable window by clicking on Ok button.
With this, we have now successfully setup Path variable as well
Install Appium
Step 2: Android Installation and Setup
This is one of the most time consuming process, and the one which is prone to errors
if not done properly. The below articles provide you with the step by step approach to
download and setup the latest version of Android SDK manager. With the latest
version of Android Studio, there are many changes in the way Android needs to be
setup. So we recommend you to use the latest version of Android Studio, so that you
can follow the steps accurately as provided in the below articles.
2. Click on Download Android Studio button. You will see the Terms and
Conditions popup
Install Appium
Step 2.1: Download and Install Android Studio
5. Double click on the downloaded exe file. Android Studio Setup Welcome Screen
would be displayed, as shown below (sometimes it might take a minute or so for the
below screen to load when you try it the first time)
Install Appium
Step 2.1: Download and Install Android Studio
6. Click on Next button. You will see the Choose Components screen. On this
screen, let both check boxes remain selected. You would observe that Android SDK
(which you need for Appium Scripts) is not displayed here. But once you install
Android Studio, and open it for the first time then you will see the option to download
Android SDK as well.
Install Appium
Step 2.1: Download and Install Android Studio
7. Click on Next button. You will now be taken to the License Agreement screen
Install Appium
Step 2.1: Download and Install Android Studio
8. Click on I Agree on the License Agreement screen. You will now see Configuration
Settings screen. Let the default installation location remain same.
Install Appium
Step 2.1: Download and Install Android Studio
9. Click on Next button. You will be taken to the Choose Start Menu Folder screen
Install Appium
Step 2.1: Download and Install Android Studio
11. Once the installation is complete, you will see the Installation Complete window as
shown below. Click on Next button. You will see Completing Android Studio Setup
screen. Uncheck Start Android Studio checkbox and then click on Finish button to
close the screen.
Install Appium
Step 2.2: Install additional Android SDK tools
1. Go to Start > All Programs > Android Studio folder and then open Android
Studio. Android Studio Welcome screen will be displayed as shown below
Install Appium
Step 2.2: Install additional Android SDK tools
4. Click on Finish button. Android Studio will now start downloading these
components
Install Appium
Step 2.2: Install additional Android SDK tools
5. When downloading is complete then click on Finish button. You will now
see Welcome to Android Studio screen
Install Appium
Step 2.2: Install additional Android SDK tools
6. Once your Android Studio project is opened, go to Tools > SDK Manager(in older
versions of Android Studio, this option was Tools > Android > SDK Manager)
Install Appium
Step 2.2: Install additional Android SDK tools
1.1 Click on Start menu. Then right click on Computer and select Properties option
Install Appium
Step 2.3: Setup Android Environment Variables
1.2 This would open the System Properties window as shown below. Now from
the Advanced Tab, click on Environment Variables button
Install Appium
Step 2.3: Setup Android Environment Variables
1.3 From the Environment Variables window, click on New button from System
variables section
Install Appium
Step 2.3: Setup Android Environment Variables
1.3 Enter ANDROID_HOME in Variable Name field and SDK folder location
(C:\Users\Anish\AppData\Local\Android\sdk) in Variable value field as shown in
below image (Please enter the correct folder location that you have in your machine)
Install Appium
Step 2.3: Setup Android Environment Variables
In Android SDK folder, there are three specific folders that you need to add to the
Path variable. These folders are –
%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\tools
%ANDROID_HOME%\tools\bin
Install Appium
Step 2.3: Setup Android Environment Variables
To verify that all the Android Environment Variables are correctly setup, open
command prompt and run this command: sdkmanager – -list
Install Appium
Step 3: Appium tool setup
With the prerequisites completed, this section covers the Appium related content.
This mainly involves setting up the latest version of Appium, and setting up your
mobile device for test automation.
platformName: It is used to set the mobile OS platform in which we‟re about to start
our session. You need to set „platformName‟ as key and „Android‟ as a value.
caps.setCapability(“platformName”,”Android”);
Understand Capabilities in Appium
platformVersion: It is used to set the mobile OS version. Each Android API has a
version. So you need to set „platformVersion‟ as key and „4.4.2‟ as value.
caps.setCapability(“platformVersion”,”4.4.2″);
appActivity: This is to set the Android activity that you want to launch from your
package. You need to set „appActivity‟ as key and „com.android.contacts‟ as value.
caps.setCapability(“appActivity”, “com.android.calculator2.Calculator”);
appPackage: This capability is for the Java package of the Android app that you want
to run. You need to set „appPackage‟ as key and your package name as value.
caps.setCapability(“appPackage”, “com.android.calculator2”);
Understand Capabilities in Appium
browserName: You need to invoke a browser to automate Mobile web apps. For
that you need to set „browserName‟ as key and your desired browser (chrome,
safari..) as value.
caps.setCapability(“browserName”, “Chrome”);
caps.setCapability(“udid”, “121111sad”);
app: Appium will install the app binary on the appropriate device. You don‟t need this
capability, if you‟re using appPackage & appActivity. You need to pass „app‟ as key
and your local path(/home/test.apk) as value to set the capability”
caps.setCapability(“app”,”/Localpath/Your.apk”);
Understand Capabilities in Appium
Adb shell
More Capabilities :
http://appium.io/docs/en/writing-running-appium/caps
Finding Mobile Elements
1. Locate Element using UIAutomatorViewer
2. Finding elements by ID
We need to pass the Xpath of the element we want to look for. It will return a
WebElement object that we can perform actions on. We are going to use the Xpath
of the digit 9; this is how the command will look:
WebElement
digit_9=driver.findElement(By.xpath("//android.widget.LinearLayout[1]/
android.widget.FrameLayout[1]/ android.widget.LinearLayout[1]/
android.support.v4.view.viewPager[1]/ android.widget.LinearLayout[1]/
android.widget.LinearLayout[1]/ android.widget.Button[3]"));
Automating Different Apps
1. The automation of Android native apps.
plus.click();
Now, we need to perform click on the
element:
five.click();
plus.click();
four.click();
equalTo.click();
Automating Different Apps
1. The automation of Android native apps.
Automating Different Apps
2. The Automated of Mobile Web app.
Step 1: Config appium desired capabilities
driver.get("https://www.google.com");
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("Appium for mobile automation");
WebElement searchButton =
driver.findElement(By.xpath("//button[@jsname='Tg7LZd']"));
searchButton.click();
Automating Different Apps
2. The Automated of Mobile Web app.
You will automate https://google.com/ on Chrome on the Android
Automating Different Apps
3. The Automated of Hybrid apps.
Step 1: Config appium desired capabilities
driver.context((String) contexts.toArray()[1]);
Automating Different Apps
3. The Automated of Hybrid apps.
Step 4: Implement action