Automation Testing of Sencha Touch based Android application


 Title

Problem Statement:

Complexities of the software applications are increasing with tremendous pace these days. Every day a new set of functionality is being added. It is the quality assurance team responsibility to make sure existing functionality will not break because of new changes and whole software application works as smooth as possible. Testing entire application for each change is desirable, but doing it manually is time consuming and may not give expected benefits.

Automation testing is the best way to overcome this problem. Prepare automation scripts and run them any number of times you want as per the project need. This saves lot of manual effort. Many automation testing tools are available for client and web based applications. As mobile platform is still evolving, we cannot find lot of automation test tools for mobile applications. But automation testing of mobile application is very much needed.

Scope of Article:

This article talks about steps to perform automation testing of Sencha Touch based application with Selenium Web driver in Andriod emulator. This article automates functional testing of sample registration application. You can download sample registration application from following link

https://github.com/walkingtree/sample-projects/tree/master/SenchaTouch/RegistrationSample

Assumptions:

This article assumes that you know about selenium web driver, if you are not familiar about selenium webdriver you can read about selenium web driver here.

Technology:

  • Sencha Touch 2.2
  • Selenium java webdriver 2.30.0 jar
  • Junit 4.10
  • Maven
  • Andriod SDK 20130219

Use cases:

Sample registration application takes set of input parameters to complete registration. Below diagram shows UI of sample registration form

form

As part of this article we prepare and run automation test script to fill all the fields of registration form and complete registration.

Steps:

 Andriod installation and Emulator setup:

  1. Download Andriod SDK(http://developer.android.com/sdk/index.html)  and unpack it and keep in the same folder where you have selenium testing java project is in place. Here webdriver folder contains java project for selenium testing

    EmulatorSetup

  2. Now install emulator for Andriod by using andriod sdk
    [suman@localhost webdriver]  $ cd andriod_sdk/tools/                                        [suman@localhost tools]$ ./android create avd -n my_andriod -t 1 -c 100M
  3. Start emulator device in your machine. You need to pass AVD name i.e. ‘my_andriod’ which is mentioned in last stepStartEmulator
  4. Verify whether emulator is running or not and note the down the device id to use in next steps                           EmualtorDeviceIt indicates emulator is running and device name is ’emualtor-5554′. This device id is used in next steps
  5. Download andriodserver from http://code.google.com/p/selenium/downloads/detail?name=android-server-2.21.0.apk&can=2&q=
  6. Install Andriod server
               ./adb -s 'emulator-5554' -e install -r  android-server.apk
  7. Now run Andriod WebDriver application
    [suman@localhost platform-tools]$ ./adb -s 'emulator-5554' shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity
    Starting: Intent { act=android.intent.action.MAIN cmp=org.openqa.selenium.android.app/.MainActivity }
  8. Now setup the port forwarding in order to forward traffic from the host machine to the emulator
    $./adb -s 'emulator-5554' forward tcp:8080 tcp:8080
  9. With this emulator andriod setup and emulator is ready for use

 Create Maven based project for Selenium WebDriver:

  1. Sample pom.xml looks like as below
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>sencha</groupId>
    <artifactId>webdriver</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
    </dependency>
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.30.0</version>
    </dependency>
    </dependencies>
    </project>
  2. Create a new unit test class for testing of touch application
    package webdriver.regresssion;
    import org.junit.Test;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.android.AndroidDriver;
    public class andriodsenchatouch {
    @Test
    public void launchTouchApplication() {
    WebDriver driver = new AndroidDriver();
    driver.get("http://192.168.1.65/senchaCmdExamples/sencha/miscellaneous/senchaTouchExample/");
    // Find the text input element by its name
    WebElement userName = driver.findElement(By.name("username"));
    // Enter something to search for
    userName.sendKeys("Suman");
    // Now submit the form. WebDriver will find the form for us from the element
    userName.submit();
    // Find the text input element by its name
    WebElement password = driver.findElement(By.name("PassWord"));
    // Enter something to search for
    password.sendKeys("empower");
    // Now submit the form. WebDriver will find the form for us from the element
    password.submit();
    // Find the text input element by its name
    WebElement reenterpass = driver.findElement(By.name("ConfirmPassword"));

    // Enter something to search for
    reenterpass.sendKeys("empower");
    // Now submit the form. WebDriver will find the form for us from the element
    reenterpass.submit();
    // Find the text input element by its name
    WebElement okbutton = driver.findElement(By.name("q"));
    // Enter something to search for
    okbutton.click();
    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());
    driver.quit();
    }
    }
  3. Now script is ready for automation testing of sample registration application

 Run prepared automation test scripts:

  1. Click on ‘Menu button in Emualtor, now on screen it shows WebDriver, that means emulator is ready for testing

    AndriodWebdriver

  2. Now go to unit test file and debug it

     DebugUnitTest

  3. Now Sencha Touch application is launched in an EmulatorLaunchApplication

Summary:

In this article we saw how we could perform automation of testing of Sencha Touch based application by using selenium webdriver

References :

Tagged with: , ,
Posted in Sencha Touch

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

We Have Moved Our Blog!

We have moved our blog to our company site. Check out https://walkingtree.tech/index.php/blog for all latest blogs.

Sencha Select Partner Sencha Training Partner
Xamarin Authorized Partner
Do More. With Sencha.

Recent Publication
%d bloggers like this: