import io.appium.java_client.AppiumDriver; import io.appium.java_client.android.AndroidDriver; import java.io.File; import java.io.FileInputStream; import java.net.URL; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; public class AppiumDemo{ protected static AppiumDriver driver = null; private static DesiredCapabilities capa = null; public static void main(String args[]){ try{ // Keep the .apk file in somewhere in your local directory , // let's say D:\apkfile\facebook.apk File app = new File("D:/apkfile/facebook.apk"); //System.out.println("Path from where app is getting installed " + app); capa = new DesiredCapabilities(); /* * Appium Server capabilities/arguments */ // Its a capability which lets Appium server know which // automation you want to use Appium or Selendroid capa.setCapability("automationName","Appium"); // Its a capability which lets Appium server know which // platform you to use Android or iOS capa.setCapability("platformName","Android"); // Its a capability which lets Appium server know // the device you are going to use capa.setCapability("deviceName","Samsung Galaxy S4"); // lets Appium server know which device it has to connect and fire the commands. // Its optional when you are working only on one device including emulator or real device connected or running. // How to get the udid , please click here to know how to get udid capa.setCapability("udid", "XXXXXXXX"); // make sure to replace XXXXXX with original udid of your device // Its a capability which lets Appium server know the OS version of your device capa.setCapability("platformVersion","5.1"); // Its a capability which lets Appium server wait for a particular time before sending next command to device capa.setCapability("newCommandTimeout","30"); // Its a capability which is used when you are dealing // with sending Unicode chars as input to (UAT) app through Appium. // Again this is option capability if you are dealing only with EN input chars capa.setCapability("unicodeKeyboard", true); // Its a capability reset keyboard to its original state, // after running Unicode tests with unicodeKeyboard capability capa.setCapability("resetKeyboard", true); // Its a capability which provide the absolute UAT application path or // you can also pass the remote path "http://xyx/fb.apk" capa.setCapability("app", app.getAbsolutePath()); // lets Appium server know which Java package of the Android app you want to run // Using this package Apps are uniquely identified on the device // How to get the package name , click here to know how to get package name capa.setCapability("appPackage", "com.facebook.katana"); // Its a capability which lets Appium server know the Activity name for // the Android activity you want to launch from your package // How to get the activity name , Click here to know how to get Activity name capa.setCapability("appActivity", ".LauncherActivity"); // Here are create the instance of Specific driver where it takes two parameter // 1. Remote URL where the server is running and listening for the requests // 2. Passing the capabilities which we set above driver = new AndroidDriver(new URL("http://127.0.0.1/wd/hub"), capa); }catch(Exception e){ System.out.println(e.getMessage()); } } }
A blog about new technology, Android, iOS, Mobile Automation, Appium, Web Automation, Selenium, JAVA, Shell Scipting, Powershell, Testing Tools, QA, Spring Boot, Free Software, How to design best frameworks etc..
Appium : Sample Demo program of Android native app automation
Subscribe to:
Post Comments (Atom)
πAnnouncement : Visit the new website/blog π
πππ Announcement : Visit the new website/blog πππ Dear readers, Thank you for reading my blog. If you could have used the little info...
-
How to find the UDID of Android Device What is UDID : It stands for Unique Device Identifier. UDID is required duri...
-
How to change language of device using commandLine Changing language in Android device on-the fly is needed when we are running or exe...
-
To setup Appium for mobile automation, you will need below items to be configured in your test environment. 1. Appium server : 1.1 D...
-
How to get the package name of Android application There are multiple ways in which we can obtain the package name of Android .apk file. ...
No comments:
Post a Comment