Appium Android Automation Starter
Jithin Somaraj
Senior QA Engineer | Specializing in Automation & Manual Testing | API Testing | Performance Testing | Expert in Enhancing Software Quality & Reliability
Introduction
Appium is an Open-source tool which can be used to automate mobile and desktop applications. Appium supports multiple programming languages like java, python, php etc.
Getting Started....
?As usual every beginners is going to scroll through the net especially YouTube for configuring and writing your first Appium project.
But the thing is it will not be successful. Not with everyone. The main Reason is that the Appium and Android sdk are updating every time so if we scroll through the older tutorials it wont work and we have to sacrifice our valuable time.
Lets see how can we do that?
?What is Needed?
Java should be installed in your Test PC which should be supported by selenium
Install Node.Js to your PC.
Install Android SDk to your PC.
Here Note that as I mentioned earlier the Android sdk is updating day to day so that check in detail the documentation otherwise you will end with an error. For me it was a Folder issue.
Installation
To install Appium in your device follow the command
npm install -g appium
It will install the latest appium in your pc.
After the installation type 'Appium' in cmd to start the appium server.
Running the Java code to Test An Application
Create a Maven project in eclipse IDE(or anything you prefer)
Make sure to add the following dependencies from maven repository
?1.Appium java client
?2.Selenium java Client
Here make sure that the above clients versions are matching with each.
After these actions connect the android device and start appium server(type appium in cmd)
You can run your code from eclipse which will execute the app.
Note : This is Just a Basic information to help with you can find easily about it from the web.
Sample Java program to Open an Application through Appium
package appium_test;
import java.net.MalformedURLException;
领英推荐
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
//import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class android {
public static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
DesiredCapabilities cap=new DesiredCapabilities();
cap.setCapability("deviceName","Galaxy");
cap.setCapability("udid", "R9PT30NK0ZB");
cap.setCapability("platformName", "Android");
cap.setCapability("platformVersion", "11");
cap.setCapability("appPackage", "com.mpayror.www");
cap.setCapability("appActivity", "com.mpayror.www.MainActivity");
cap.setCapability("automationName", "UiAUtomator2");
Object packageCap = cap.getCapability("appPackage");
String pack = packageCap.toString();
System.out.println(pack);
URL url = new URL("https://0.0.0.0:4723/wd/hub");
?driver?= new AndroidDriver(url,cap);
?System.out.println("Application Started");
}