Thursday, 2 June 2016

Appium Mobile Automation


What is Appium:

Appium is an open source mobile automation testing tool for native,hybrid and mobile web appilcations.

-Native apps are pure mobile applications. For example gaming app,calculator.,
Native app is build with specific language such a object C for IOS and java for Android.
-Mobile web applications will look like mobile app but when user click on app it will launch as web app . For example: chrome, Firefox.,
-Hybrid App is  web view hosted inside a native container:  For exaple:  Facebook,Twitter

Simply how we can defined is "Selenium 2"+ Mobile Features=Appium.


Where Appium is tested.

Appium is tested in Simulator (iOS, Firefox OS), emulator (Android)  and real Devices (iOS, Firefox OS,Android)


Why Appium

1. Can write code any language supported by selenium webdriver.(Appium is an extension of webdriver)
2. Appium library can be used as cross platform. Common code method can be used for both android and iOS.
3. Appium is open source tools.

Appium Architecture(Client/Server architecture) 


-Code written in any language will be sent via JSON wire protocol to appium server and code will be received in the form of HTML session object.
-Appium server will understand the command which is sent from client library and triggers the particular invocation in the mobile. Here Appium is act like a proxy between client library and Mobile
-Appium server contain UI Automator & iOS Instrumentation framework to test Android/iOS app.
-Appium is an HTTP server writen in Node.js programming language.
-Bootsrap.js will perform all operation  in simulator/emulator which is sent from appium client and will send response back to appium client. 

Pre- Requisite for Appium testing

1. Download JDK and configure Path in "Advance System Settings --> Advance--> Environment Variable" :
a) create system variable
variable  name=JAVA_HOME              variable  value= C:\Program Files\Java\jdk1.8.0_51
b) add java bin to path variable
variable  name=Path              variable  value= "already existing path" ;C:\Program Files (x86)\Java\jre1.8.0_51\bin

How to check Install is done:  You can check through command prompt. Run command prompt and type "java -version". Here command prompt should show the java version.


2. Download and install Android SDK. Use below link.
http://developer.android.com/sdk/installing/index.html
Here run sdkmanager.exe file.

a). Configure the environment variable:

variable = ANDROID_HOME         path = C:\Users\Admin\AppData\Local\Android\sdk
b) Edit path variable
variable  name=Path     variable  value= "already existing path";%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
Note: Android we need to set two path variable. One for platform-tools and another for tools

3. Download Eclipse and launch eclipse.exe file.
4. Add andoid Adt plug in to exlipse
Go to eclipse--> Help-->Install New Software 
Here enter the link (https://dl-ssl.google.com/android/eclipse/) to download adt plugin and click on enter button 
Search will result Developer tools , select the check box and for for installation(click on Next-> Next)
Provide sdk locations: C:\Users\Admin\AppData\Local\Android\sdk 

Note: Once the configuration is done then restart the eclipse
How to check Install is done: Go to eclipse--> Windows--> Preference:  and make sure "Android" is listed in it.

5) Windows-> perspective --> customized perspective
here select Android sdk and avd manager checkbox in toolbar visibility section.

Once it is done you can see an "Android Virtual Device Manager" icon in eclipse.


Click on android virtual device and create a new virtual device.

  a) Click on create and fill  AVD name: Demo
                                        Device : selec any from drop down
                                        Target :  go for default
                                        Emulation option: select "Use Host GPU " to increase performance.

  b) Click on ok
  c) Click on start button , now virtual device will get launched.
Alternative: Go to sdk folder and launch AVD Manager.exe file.

6) Download .net framework and install in your system
https://www.microsoft.com/en-us/download/details.aspx?id=30653 

7) Download and install appium server for windows.
http://appium.io/downloads.html

8) Download selenium and appium jar files
Selenium jar files: http://docs.seleniumhq.org/download/
Appium jar files:   http://mvnrepository.com/artifact/io.appium/java-client/2.2.0


Create a Firs Demo Project in Appium

Here you go with first program
1. Download an .apk file from android "https://play.google.com/store/apps?hl=en"
2. Write the below code in eclipse

 DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
   desiredCapabilities.setCapability("deviceName", "Android Emulator");
   desiredCapabilities.setCapability("platformName", "android");
   desiredCapabilities.setCapability("platformVersion", "4.4.4");
   
   desiredCapabilities.setCapability("app", "G://Appium//WhatsApp.apk");
   WebDriver driver;

   driver = new RemoteWebDriver(new URL("http://127.0.0.1:4730/wd/hub"), desiredCapabilities);

3. Launch Appium and wait for few seconds to make sure appium running successfully.
4. Now invoke android vertual device
5. Execute eclipse code.
























No comments:

Post a Comment