Appium - Run First Android Automation Test Using In Eclipse

We cause got configured appium projection inward eclipse during previous post. Now nosotros are all laid to practice too run outset appium software automation test script on android mobile device. In this steps nosotros volition larn how to practice first appium automation softwre examine script inward eclipse too and therefore run it inward existent android mobile device.


PREREQUISITE : All previous 12 STEPS should move completed without whatever error.

We volition role android mobile phone's default installed figurer app to run appium software automation examine script. You tin hand notice download Android Calculator software App from THIS PAGE if it is non installed inward your mobile. This is our outset appium software examine therefore nosotros volition practice uncomplicated examine to amount 2 numbers. Follow the steps given bellow.

1. Gather Required Capabilities
Before creating appium examine for android software app, You necessitate bellow given parameters of android device too app to laid webdriver capabilities inward examine script.
  1. Find Android Device Name : As described inward THIS POST, Connect your android device alongside PC too conk device cite past times running adb devices ascendance inward ascendance prompt. My android device cite Is : ZX1B32FFXF. Find your device name.
  2. Find Android Software App Package Name : You tin hand notice persuasion THIS POST to know how to conk android app parcel name. Package cite for my calculator app (Which Is Installed inward my android device) is com.android.calculator2. Find your app parcel name.
  3. Find App Activity Name : You tin hand notice persuasion THIS POST to know how to conk android app action name. Activity cite for my calculator app (Which Is Installed inward my android device) is com.android.calculator2.Calculator. Find your app action name.
  4. Find Android OS Version : In your android device, Open settings -> About band -> Android version. My device's Android version Is : 4.4.2.
2. Launch And Start Appium Node Server
Appium should move installed too configured too too yous necessitate Server Address too Port number (which is used past times appium) every bit described inward THIS POST.

Launch Appium
  • Launch Appium from Windows Start menu.


  • For me, Server Address is : 127.0.0.1 and Port Number is : 4723.
Start Appium Node Server
Click on Start push to start appium node server every bit shown inward bellow image. It volition accept approximately fourth dimension to launch node server.

Note : You tin hand notice regard appium node server is started properly 1 time it shows log every bit shown inward higher upward image.

3. Create Appium Test Script In Eclipse
I cause got created sample appium software examine script using selenium webdriver to amount 2 numbers using android figurer application.

Prerequisite :
  • Calculator app should move installed inward your android device.
  • Install TestNG inward eclipse if it is non installed. View THIS POST.
  • Also supersede capabilities values of bellow given listing alongside your ain values inward script. Otherwise it volition non works.
  1. deviceName - Name of device which is connected alongside PC.
  2. CapabilityType.VERSION - OS version of your android device.
  3. appPackage - Calculator app's Package name.
  4. appActivity - Calculator app's Activity name.
Now practice bellow given examine degree nether Android parcel of your appium project. Usage of each code syntax is given inward script itself.

SimpleAndroidCalcTest.java
package Android;  import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit;  import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test;  populace degree SimpleAndroidCalcTest {   WebDriver driver;   @BeforeTest  populace void setUp() throws MalformedURLException {   // Created object of DesiredCapabilities class.   DesiredCapabilities capabilities = novel DesiredCapabilities();    // Set android deviceName desired capability. Set your device name.   capabilities.setCapability("deviceName", "ZX1B32FFXF");    // Set BROWSER_NAME desired capability. It's Android inward our instance here.   capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");    // Set android VERSION desired capability. Set your mobile device's OS version.   capabilities.setCapability(CapabilityType.VERSION, "4.4.2");    // Set android platformName desired capability. It's Android inward our instance here.   capabilities.setCapability("platformName", "Android");    // Set android appPackage desired capability. It is   // com.android.calculator2 for figurer application.   // Set your application's appPackage if yous are using whatever other app.   capabilities.setCapability("appPackage", "com.android.calculator2");    // Set android appActivity desired capability. It is   // com.android.calculator2.Calculator for figurer application.   // Set your application's appPackage if yous are using whatever other app.   capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");    // Created object of RemoteWebDriver volition all laid capabilities.   // Set appium server address too port pose out inward URL string.   // It volition launch figurer app inward android device.   driver = novel RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);   driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);  }   @Test  populace void Sum() {   // Click on DELETE/CLR push to clear effect text box earlier running test.   driver.findElements(By.xpath("//android.widget.Button")).get(0).click();    // Click on pose out 2 button.   driver.findElement(By.name("2")).click();    // Click on + button.   driver.findElement(By.name("+")).click();    // Click on pose out v button.   driver.findElement(By.name("5")).click();    // Click on = button.   driver.findElement(By.name("=")).click();    // Get effect from effect text box.   String effect = driver.findElement(By.className("android.widget.EditText")).getText();   System.out.println("Number amount effect is : " + result);   }  @AfterTest  populace void End() {   driver.quit();  } }

Note : Before running higher upward script using testng, Please brand certain your android device is connected alongside PC alongside USB debugging means enabled too Appiun node server is launched too started.

4. Running  Appium Test Script 
I promise yous already know how to run software examine script using testng (VIEW EXAMPLE). Run higher upward examine script too persuasion your android band screen. It will 
  • Open figurer app inward your mobile device.
  • Tap on buttons inward this sequence -> CLR, 2, +, v too =.
  • Get effect from text expanse of figurer app.
  • Print effect inward eclipse console.
This way, We cause got executed real uncomplicated examine script inward android mobile device. If yous cause got noticed inward higher upward illustration examine script, We cause got used solely cite locator. We volition role all dissimilar chemical gene locators (Which are described inward THIS POST) inward upcoming examples.


More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post