Skip to content

Tag: rhbroms

Mobile Application Testing

Mobile Application Testing

If anybody wants to use / copy this tutorial to their Website or Blog please feel free to contact me at my personal email id:
Manual Testing


1. What is Mobile Application Testing?

2. Difference Between Mobile Testing and Mobile Application Testing.

3. Mobile Application Extensions and Small intro about Android Platform.

4. How to Test a Mobile Application?

Automation Testing

Click on the below Topics to Lean Automation Testing.

It will take only 2-3 days to learn If you are good at Java.

1. Robotium for Android Application Testing.


1. What is Mobile Application Testing?

It is somewhat similar to software testing but the testing will be performed on a mobile device instead of performing on a system.

Types of Mobile application Testing are: 

1. Installation testing.

2. Functional Testing.

3. Memory Leakage Testing.

4. Interrupt Testing.

5. Usability testing.

6. Certification Testing.

7. Performance Testing.

8. Integration Testing.

9. System Testing.

10. Accessibility Testing.

11. Adhoc(Monkey) Testing.

The all above points will be discussed in chapter 4:


2. Difference Between Mobile Testing and Mobile Application Testing.

Mobile Testing

– Mobile Testing is testing of Mobile Handsets or Devices.

– Here we mainly concentrate on Native applications(Blot wares).

– Testing all the core like SMS, Voice calls, Connectivity(Bluetooth), Battery(Charging), Signal receiving, Network are working correctly.

– Testing is conducted on both hardware and software.

Mobile Application Testing

– Mobile Application Testing is the testing of mobile applications which we are making as third party for the targeted mobile handset.

– Some core feature of the mobile are tested just to see that your application has not created any side effects on the device functionality.


3. Mobile Application Extensions and Small intro about Android Platform.

Below are some Mobile Platforms given with respective File Extensions

1. Android – .apk (Android application package file)

2. Iphone – .ipa (iOS application archive file)

3. Symbian – .sis (Software Installation Script)

4. J2ME – .jad and .jar (Java Application Descriptor and Java ARchive)

5. RIM – .alx and .cod

6. Windows Mobile – .cab

7. Bada – .jad and .jar (Java Application Descriptor and Java ARchive)

Android Platform

Testing Purpose we should have to know about the android architecture as well as about Android Versions. Details On this discussed below:

Architecture of Android:

Android operating system is a stack of software components which is roughly divided into five sections and four main layers as shown below in the architecture diagram:

Image and video hosting by TinyPic

Linux kernel
At the bottom of the layers is Linux – Linux 2.6 with approximately 115 patches. This provides basic system functionality like process management, memory management, device management like camera, keypad, display etc. Also, the kernel handles all the things that Linux is really good at such as networking and a vast array of device drivers, which take the pain out of interfacing to peripheral hardware.


On top of Linux kernel there is a set of libraries including open-source Web browser engine WebKit, well known library libc, SQLite database which is a useful repository for storage and sharing of application data, libraries to play and record audio and video, SSL libraries responsible for Internet security etc.

Android Runtime
This is the third section of the architecture and available on the second layer from the bottom. This section provides a key component called Dalvik Virtual Machine which is a kind of Java Virtual Machine specially designed and optimized for Android.

The Dalvik VM makes use of Linux core features like memory management and multi-threading, which is intrinsic in the Java language. The Dalvik VM enables every Android application to run in its own process, with its own instance of the Dalvik virtual machine.

The Android runtime also provides a set of core libraries which enable Android application developers to write Android applications using standard Java programming language.

Application Framework
The Application Framework layer provides many higher-level services to applications in the form of Java classes. Application developers are allowed to make use of these services in their applications.

You will find all the Android application at the top layer. You will write your application to be installed on this layer only. Examples of such applications are Contacts Books, Browser, Games etc.

Android Application Activity Lifecycle

The life cycle of an activity with main methods as shown below:

Image and video hosting by TinyPic

onCreate() This is the first callback and called when the activity is first created.

onStart() This callback is called when the activity becomes visible to the user.

onResume() This is called when the user starts interacting with the application.

onPause() The paused activity does not receive user input and cannot execute any code and called when the current activity is being paused and the previous activity is being resumed.

onStop() This callback is called when the activity is no longer visible.

onDestroy() This callback is called before the activity is destroyed by the system.

onRestart() This callback is called when the activity restarts after stopping it.

If you know this much it is enough to Go ahead with Mobile application testing in Android platform.


4. How to Test a Mobile Application?

1. Installation testing:

To Verify application can be installed successfully.

Different ways of Installing an application to Android Device:

1(a). OTA(Over The Air) : We can install our application by using android play store app on the mobile or else by browsing into Google playstore website. This can be done using WiFi as well as by using GPRS connection.

1(b). Sideloading From Your PC : To do this we need ADB(Android Debug Bridge). This is a very simplest way to install any 3rd party app to your device, most of the time we test engineers prefer this way only.

Just download and Install Android SDK to your system and follow the below steps:

1. Download the application (APK) file to a folder of your choice on your computer.

2. Connect the phone to the computer through the USB port.

3. Enable installation of non-market applications on your phone:

a. On your phone, open the Applications menu (i.e., the tab in the bottom center of the
phone’s home screen) and click on the Settings application, then select Applications
from the Settings menu.

b. Make sure that the first selection, Unknown Sources, is checked so that you can install
an APK file from a location other than the Android Market. A warning message about
the phone being vulnerable to attack will be displayed. Select OK to continue if you
trust the APK file you are about to download. You can change this setting back after the
current installation is complete.

4. Turn on “USB debugging” on your phone: open the Applications menu and select Development,
then enable USB debugging.

5. Open a command/terminal window:

• On Windows, select Start > Run> then type ‘cmd’.
• On Mac OS X, open the Applications folder, select Utilities, then Terminal.
• On Linux, select Applications > Accessories > Terminal.

6. In the command/terminal window, enter the following command:


adb install <APK_FILE_PATH><APK_FILE>

2. Functional Testing:

Testing the functionality of the application with respect to given requirements of the application.

2(a). Application LOGO Test: Testing the logo of the application to check whether the app which is under test have used the proper logo as per the requirement specification or not.

2(b). Application Splash Screen Test: To verify that when user selects application logo in application manager splash is displayed.
Note that Splash do not remain for more than 3 seconds.

2(c). Application Background Image Test: To test whether the application under test is using the proper Background image as per given requirement specification or not.

2(d). Font style / size / color: Testing the Font size/style/color as per requirement specification.

2(e). Layout: Testing the layouts with respect to given requirement specification.

2(f). Back Key: Verify that back key should navigate the user to previous screen or should close the application with proper exit popup dialog(Again it depends on Requirement specification).

2(g). Application Start/Restart: 
i. Find the application icon and select it
ii. Observe the application launch In the timeline defined.
iii. Application must not take more than 25s to start

2(h). Exit Application: Verify that user is able to exit from application with every form of exit modes like Flip, Slider, End Key or Exit option in application and from any point.

3. Memory Leakage Testing

Memory leakage happens when a computer program or application is unable to manage the memory it is allocated resulting in poor performance of the application and the overall slowdown of the system. As mobile devices have significant constraints of available memory, memory leakage testing is crucial for the proper functioning of an application.

4. Interrupt Testing

An application while functioning may face several interruptions like incoming calls or network coverage outage and recovery. The different types of interruptions are:

  • Incoming and Outgoing SMS and MMS.
  • Incoming and Outgoing calls.
  • Incoming Notifications.
  • Battery Removal.
  • Cable Insertion and Removal for data transfer.
  • Network outage and recovery.
  • Media Player on/off.
  • Device Power cycle.

An application should be able to handle these interruptions by going into a suspended state and resuming afterwards.

5. Usability testing

Checking the user-friendliness of the application is known as Usability testing.

We have to verify if the application is achieving its goals and getting a favorable response from users. The application should have to give the results in very few steps or in few clicks.

The best example for this is: If you are booking a movie ticket by using some application, user should get the ticket booked in a very short amount of time / only by using 3-4 activities maximum!!

6. Certification Testing

Use this command : (Jarsigner is in your Java bin folder goto java->jdk->bin path in cmd prompt)


$ jarsigner -verify -verbose -certs my_application.apk

If you see “CN=Android Debug”, this means the .apk was signed with the debug key generated by the Android SDK (means it is unsigned), else u will find something for CN. for more details…p-signing.html

How do developer signs their apps: 

Dev creates a keystore file by using the below cmd:


$ keytool -genkey -v -keystore my-release-key.keystore
-alias alias_name -keyalg RSA -keysize 2048 -validity 10000

To show you how it works I have given a screen shot of creating one below:

Image and video hosting by TinyPic

After generating key we have to follow the following steps:

  • Right click on project > Android Tools > Export Signed Application Package
  • The Export Android Application wizard appears.
  • Select the project I want to export, click Next.
  • The Keystore Selection screen appears.
  • Select the keystore and enter the password.

Image and video hosting by TinyPic

After this just give the path of the .apk file that has to be released.

Image and video hosting by TinyPic

7. Performance Testing

This testing process is undertaken to check the performance and behavior of the application under certain conditions such as low battery, bad network coverage, low available memory, simultaneous access to application’s server by several users and other conditions. Performance of an application can be affected from two sides: application’s server side and client’s side. Performance testing is carried out to check both.

This is done by performance test engineers. They use specific tools for this, for example: LoadRunner, Apache JMeter etc…

8. Integration Testing

Testing the data flow between two modules(activities) is called to be as Integration Testing.

This is done after finishing of Functional Testing.

The reason why we do Integration Testing is to make sure that all the activities are connected together properly or not.

9. System Testing

It is a end to end testing of the application where in Testing Environment is similar to production.

Here we test the data flow from the beginning to the end, If something is broken we have to report it as a bug.

We perform system testing after finishing of Integration Testing.

We perform system testing to make sure that end to end scenarios of the application is working properly or not.

10. Accessibility Testing

Accessibility testing is a subset of usability testing where the users under consideration have disabilities that affect how they use the application. The end goal, in both usability and accessibility, is to discover how easily people can use application and feed that information back into improving future designs and implementations.

This testing is done after completion of system testing.

11. Adhoc Testing(Monkey Testing)

Testing the application in a random way is called to be as Adhoc or Monkey Testing.

Monkey Testing is done after completion of full software testing and reporting of all the bugs is done. And also when the product is almost stable.

The reason why we perform this testing is,

  • To some how brake the product.
  • To find more number of bugs.
  • To make the software more stable.
Leave a Comment


Table of Contents:

1. Robotium

2. What all we need before we get it started?

3. How to setup Robotium using Eclipse ADT with source code of Android Application?
3a. Basic Android Test Project with source code

4. How to setup Robotium using Eclipse ADT without source code of Android Application?
4a. Basic Android Test Project without source code

5. What is JUnit Test Suite and why we need it with Robotium?

6. How to Data-Drive Robotium Scripts?

7. Issues or challenges with Robotium


Please skip to second post If you are reading this post for the first time


ROBOTIUM 5.2.1 Released


New Features and bug Fix details:


unlockScreen() – Unlocks the screen lock.

getCurrentViews(Class<T> classToFilterBy, boolean includeSubclasses) – New parameter includeSubclasses set to true if also subclasses should be returned.

scrollToSide(Side side, float scrollPosition, int stepCount) – Added parameter stepCount to allow for users to decide the speed of the scroll.

scrollViewToSide(View view, Side side, float scrollPosition, int stepCount) – Added parameter stepCount to allow for users to decide the speed of the scroll.

Bugs fixed:

Issue-600 – ViewFetcher, getRecentDecorView fails on Samsung S4 with MultiWindow support

Issue-579 – Screenshots do not get saved

Issue-589 – waitForFragment on vers < 3.0

Issue-615 – ScrollToSide opens the navigation bar

I hope you will enjoy this release!

Link To Download: CLICK HERE

Robotium Recorder 2.0 is released!

Renas Reda
Founder and CEO at Robotium Tech
We’re excited to announce the release of Robotium Recorder 2.0. Thanks to all the feedback that we’ve received, we’ve been able to make hundreds of improvements since it first launched. It’s now compatible with more apps and is optimized to generate even smarter tests than before.New in Robotium Recorder 2.0:– Improved click and gesture support.- Click to Assert™ has been further refined and is now performing optimally in a broad range of apps.- Record click and drag coordinates by selecting the option in “Settings”.- Full support for GL apps and games by enabling touch and drag coordinates.- After a test case has been saved it can now be executed directly from Robotium Recorder by clicking “Run Test”.

Robotium Recorder 2.0 comes with a new trial period, so even if you have consumed the trial of the old version you are now able to try this new version as well.

To update Robotium Recorder, in Eclipse go to Help –> “Check for updates”

Details on how to install explained in the Old posts below.

“““““““““““““““““““““““““ “““““““““““““““““““““““““ ` “““““““““““““““““““““““““ “


ROBOTIUM 5.0.1 Got Released !!!

Robotium Rec. Latest Update: 1.4.11 (23/01/14)


Robotium Recorder updates are releasing almost daily.. The first update what I got was 1.2.95 and now we have the latest update as 1.4.5 (22/01/14). I will be updating this post as I find new updates…

Renas Reda
Founder and maintainer of Robotium



We’re happy to announce the release of Robotium 5.0.1! Included in this release is a new Config class, where Robotium Developers can change various things like default timeouts, screenshot location, screenshot type, scrolling, and web element click behaviour.

We’ve been working hard on improving the various click methods by testing numerous popular apps under sub-par performances to add further logic to the click methods and thus reduce click issues. In the last year we’ve gone through the whole code base and improved various areas. This is an update we recommend for everyone using older Robotium versions.

The new changes in 5.0.1 are as follows,

NOTE: The package name has been changed to com.robotium.solo. You’ll need to update the import line at the top of your current test classes from to com.robotium.solo.

New functionality in Robotium 5.0.1:

pressSoftKeyboardNextButton() – Presses the next button on the soft keyboard.

waitForEmptyActivityStack(int timeout) – Waits until the Activity stack is empty.

New Class com.robotium.solo.Solo.Config:

int timeout_large – The timeout length of the waitFor methods. Default length is 20 000 milliseconds.

int timeout_small – The timeout length of the get, is, set, assert, enter and click methods. Default length is 10 000 milliseconds.

String screenshotSavePath – The screenshot save path. Default save path is /sdcard/Robotium-Screenshots/.

ScreenshotFileType screenshotFileType – The screenshot file type, JPEG or PNG. Use ScreenshotFileType.JPEG or ScreenshotFileType.PNG. Default file type is JPEG.

boolean shouldScroll – Set to true if the get, is, set, enter, type and click methods should scroll. Default value is true.

boolean useJavaScriptToClickWebElements – Set to true if JavaScript should be used to click WebElements. Default value is false.


All the click methods. Improved behaviour in unfavorable situations.

The waitForDialogToOpen & waitForDialogToClose methods. Now recognises all dialogs.

The internal View handling class.

TakeScreenshot() now supports GLSurfaceViews with OpenGL ES 3.0.

See the Javadoc for an example on how to use the new Config class.

We hope you will enjoy this release!


This will be a Full Tutorial on Robotium Android Automation Tool
I will be updating this thread as I get time. SO NO ETA’s.


If anybody wants to use / copy this tutorial to their Website or Blog please feel free to contact me at my personal email id:
or at our official Website:


Please Click on Thanks button if this tutorial by me had helped you for some extent !!!

User Guide for Robotium Recorder ( Skip this guide if you are reading this post for the first time and move on with the second post..)

Link to Robotium Official website: Click Here


Install Robotium Recorder, if not already installed.

Connect a device (recommended) or start an emulator with external storage.

Start Robotium Recorder

Start Robotium Recorder from the toolbar: Eclipse > New > Other > Android – Robotium Recorder.

Robotium Recorder can also be started by right clicking an existing app or test project and from the opened menu select: Robotium Recorder > New Robotium Test.

Record test cases from a workspace project

From Robotium Recorder it’s possible to select either a binary (APK file) or a workspace project to record test cases from. In the screenshot below a workspace project has been selected. Enter a test project name and click “Next”.

Record test cases from a binary APK

To record test cases from an APK, click “select apk”. A file browser will be opened where the APK can be selected. Robotium Recorder will automatically sign the APK with the local debug certificate.

Once the signing process has finished the “Next” button will be enabled.

Start recording

Clicking Next on the previous screen will show the recording screen.

In the left bottom corner there is Setting menu with three options:

a. Use sleeps – choose if sleeps should be used to playback test cases in the same speed as they were recorded. Can be useful for slower apps like bandwidth intensive or hybrid apps.

b. Keep app data – choose if app data is to be kept when starting a new recording session.

c. Identify class over string – default View identifier is always the resource ID. In the event a resource ID is missing it’s possible to choose if a View class identifier is to be used over a string identifier (the text displayed by the View).

Click “New Robotium Test”.

If an APK is selected, Robotium Recorder will first install the re-signed APK on the device or emulator.

When installation of the workspace project or APK is done the recording will be started.

The app is executed on the device or emulator and recording of user actions starts.

The recorded steps are shown in the test step table (as seen below)

If a test step is selected in the table the “Delete step” and “Take screenshot” buttons will be enabled.

1. Select any step in the table and click on “Delete step” to delete it.

2. Click “Take screenshot” to add a screenshot step after the selected step.

To stop the recording click “Stop Recording”.

To save the test case click “Save”, enter a test case name, and click “Ok”.

If the test project already exists it will save the test case in that project. Otherwise it will first create the test project and then save the test case. Either start a new recording or close Robotium Recorder by clicking “Finish”.

To see the saved test case(s) expand the test project and look in the src folder. The whole test project or a specific test case can be executed by right clicking it and selecting Run As > Android JUnit Test.

1. Robotium


Robotium is an open-source test framework for writing automated Black-box test casesfor Android applications (Native/3rd party). With Robotium we can write function, systemand acceptance test scenarios.

Robotium can be used both for testing of apps where source code is available and appswhere only APK (Android Application Package) file is available and the implementation will be discussed in 4th chapter.

Robotium frame work released under Apache License 2.0. Its founder and main developeris Renas Reda. Latest Version of Robotium is 4.3.1(At the point of writing this book). The home page of Robotium is located under the following URL Robotium Home Page

Robotium extends the Android test framework to make it simpler to write tests. The main class for testing with Robotium is Solo.
Solo is initialized with the instrumentation of the test case and the first activity to test.

2. What all we need before we get it started?

We need the below:

1. Windows 7/8 OS
2. Java 6
3. Eclipse ADT
4. Android device running min android version 2.3.4*
5. Robotium Jar files (Robotium-solo-4.3.1.jar and Robotium-solo-4.3.1-javadoc.jar)
6. POI Jar files
7. Source code of the app to be tested*

*Are not mandatory.


SimpleCalc app sourcecode: SimpleCalc

Robotium jar files : file1 and file2

POI jar files:


3. How to setup Robotium using Eclipse ADT with source code of Android Application?


1.Open Eclipse ADT.

2.Import the source code of the application (to be tested) to eclipse.

3.I have given a source code which is written by me for testing purpose, you can find it here. [To import the project go to File ->Import -> select General -> Archive file -> Click on finish button]

4. Remove all the Errors as well as Lint warnings that might be present in the project by right clicking on the project (SimpleCalc) -> properties -> Android Lint Preferences -> Click on Ignore all button.

5. Create new Android Test project (Go to File -> New -> Other.. -> Select Android Test Project and give the project name as SimpleCalc-test). Details shown from the belowscreen shots:

NOTE: Select the option “An existing Android project” and select SimpleCalc project and click on Next button, this means you are going to test SimpleCalc app which is given by me.

6. Now right click on the empty package file that you get (Project_Name -> src -> Package) and select new Junit test case as show in below screen shot.

7. Now you will see a window where in you have to specify the Name of Junit test case as shown below (give it as TestCase_1):

8. Now you have to create new folder with name Robotium

9. Inside the Robotium folder paste the downloaded Robotium jar files.

10. Now go to Java Build Path by right clicking on the project -> properties and add the Robotium jar file as shown below:

11. Now click on the dropdown list of the Robotium jar file and select javadoc option as shown below:

12. Click on edit button and use the Robotium-solo-4.3.1-javadoc file as shown in the belowscreen shot:

13. Now go to Order and Export tab and click on select all button as shown below and click ok button:

3a. Basic Android Test Project with Source Code

1. Now your project will somewhat look like below:

2. Now we have to do some editing work to make this test case work as shown below:


package com.rhb.simplecalc.test;

import com.rhb.simplecalc.MainActivity; // we have to import this class for testing our SimpleCalc application

import android.test.ActivityInstrumentationTestCase2; // You can run any test method on the UI thread

public class TestCase1 extends ActivityInstrumentationTestCase2<MainActivity> {

private Solo solo; // solo is the main class of Robotium

public TestCase1() {
super(MainActivity.class); // Activity name of the class that you want to test.
// TODO Auto-generated constructor stub

public void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());

public void test() throws Exception{

// check that we have the right activity
solo.assertCurrentActivity(“wrong activiy”, MainActivity.class);

// enter the value “12” into first edit text
solo.enterText(0, “12”);

// enter the value “2” into first edit text
solo.enterText(1, “2”);

// Click on the first button

// searchForText has a timeout of 5 seconds

public void tearDown() throws Exception {
solo.finishOpenedActivities(); // finishes all opened activities


3. To Run the test just right click on the SimpleCalc-Test project -> Run As -> Android JUnit Test

4. Now you will see a tab of JUnit where in you will see your test results(Passed/Failed).

5. On the below Screen Shot I have shown you how the JUnit results are shown when the test is pass.

6. As you can see from the above screen shot clearly that our test is pass and the color indication is Green. If in case our test gets failed the color will be changed to Red as shown in below screen shot:

7. And the Fail reason will be shown at the Failure Trace as you can see from the above screen shot. Here I have purposely commented on the both edittext fields so that I can show you how the failed test case report will be.

8. Now the thing is how to take out the report? It’s easy, there are 3 ways of doing it they are:

8(a). By taking Logcat.

8(b). By Clicking on the Test Run History -> Export option you will get a xml file of the test report, and lastly.

8(c). Pushing the Test report to a text or excel file to the device.

9. Now we will see how to test the application when we don’t have source code with us in the next chapter.

4. How to setup Robotium using Eclipse ADT without source code of Android Application?

1. To get it started first let us see what is an apk file, why we need it? How to install it to a device?

2. Android application package file (APK) is the file format used to distribute and install application software and middleware onto Google’s Android operating system. APK files are ZIP file formatted packages based on the JAR file format, with .apk file extensions.

3. We need apk file to test our application without having the source code. Now the question is from where do I get the apk file? It’s Easy just go to workspace of eclipse -> open the folder called SimpleCalc -> bin -> SimpleCalc.apk (~279KB).

4. To install SimpleCalc.apk file we are going to use a simple adb (Android Debug Bridge) command. The syntax for install an apk file is as below:


adb install [path of the apk file]

NOTE: Before Installing an apk file the important thing is to make sure that your device is in debugging mode and your device is connected to your Computer System. To enable debug mode in to your device go to Settings -> Developer options -> check mark Android debugging option.

4a. Basic Android Test Project without source code

1. Now as we are done with installing our apk file to device the next thing is very important, that is we have to create a new android test project so for this we have to keep at least one project open (It can be any project) and then only we can proceed else we will get an error saying which is show as below:

2. Now go to file -> new -> other -> Android Test Project -> give a name as SimpleCalcAPK-Test -> Select Test Target as “An existing Android project” -> Finish.

3. Now you will find a project with an empty package ready for creation of JUnit tests without source code.

4. Right click on the empty project -> new -> JUnit Test Case and give a name as ApkTestCase_1. Now you will see JUnit test case as below:

5. Now edit the above code as show below:


package com.rhb.simplecalc.test.test;


import android.test.ActivityInstrumentationTestCase2;

public class ApkTestCase_1 extends ActivityInstrumentationTestCase2 {

public ApkTestCase_1() {
// TODO Auto-generated constructor stub

private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = “com.rhb.Simplecalc.MainActivity”;

private static Class MainActivity; // name of the activity class

try {
MainActivity = Class
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);

private Solo solo;

public void test() throws Exception{
solo.enterText(0, “12”);
solo.enterText(1, “2”);

protected void setUp() throws Exception {

protected void tearDown() throws Exception {


6. As soon as you Run this test you will get an Error saying “Process crashed” as shown below:

7. Solution for this is we have to just change the below lines from AndroidMenifest.xml file :

HTML Code:
        android:targetPackage="com.rhb.simplecalc.test" />

Change it to:

HTML Code:
        android:targetPackage="com.rhb.simplecalc" />

NOTE: The “targetPackage” will be the package called by the test which tests the functionality of the application in that called package.

8. Now copy paste the below code to test SimpleCalc application without source code:


package com.rhb.simplecalc.test.test;


import android.test.ActivityInstrumentationTestCase2;

public class ApkTestCase_1 extends ActivityInstrumentationTestCase2 {

public ApkTestCase_1() throws ClassNotFoundException {
// TODO Auto-generated constructor stub

private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = “com.rhb.simplecalc.MainActivity”; // name of the package with activity name here com.rhb.simplecalc is the package name and MainActivity is the activity name to be executed.

private static Class MainActivity; // name of the activity class

try {
MainActivity = Class
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);

private Solo solo;

protected void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());

public void test() throws Exception{

// solo.assertCurrentActivity(“wrong activiy”, MainActivity);
solo.enterText(0, “1”);
solo.enterText(1, “2”);

protected void tearDown() throws Exception {


10. Now Run the project by right clicking on the project -> RunAs -> Android Junit Test and see the test results in the Junit tab.

5. What is JUnit Test Suite and why we need it in Robotium?

1.JUnit Test Suite is a collection of multiple unit tests each of which shall test the functionality of a Robotium script.

2.Android sdk comes built in with android jUnit which is different from the normal jUnit however the structure of android jUnit resembles that of regular JUnit. This is the reason why we need JUnit suit to call all the Robotium scripts and thereby used in android automation.

3.One JUnit suite shall call multiple activities of the application and therefore for bigger applications. It is possible to have multiple JUnit suits and we can further have a collection of these suites under a suite of suits(collection of individual JUnit suits).

4.Now we will write a simple JUnit test for our application which is as below:

As I said before normal JUnit Suite is different and android JUnit is different we have to do some modifications on the coding part to make JUnit suite work on android, which is as below:


package com.rhb.simplecalc.test.test;

import android.test.AndroidTestCase; // to make JUnitSuite work with android

public class JunitSuite extends AndroidTestCase {

public void setUp() throws Exception {

// first JUnit Suite that will call ApkTestCase_1 class
public void Test() throws Exception {

ApkTestCase_1 a = new ApkTestCase_1();


public void tearDown() throws Exception {


5.Now I will show you how to create Main Suite which intern calls all the subsuites which are present in the test project.


package com.rhb.simplecalc.test.test;

import junit.framework.Test;
import junit.framework.TestSuite;

public class MainSuite extends TestSuite {

public static Test suite () {
TestSuite suite = new TestSuite();

JunitSuite test = new JunitSuite();

return suite;

6.Now as we are done with creating of JUnit Suite we will continue with creation of Data Driven testing in the next chapter.

6. How to Data-Drive Robotium Scripts?

1.We go for data driven testing when we have some modules that need to be tested for multiple values. For example in a application which has a login page with username and password field we have to test these edit text boxes for multiple inputs, it can be a number or it also can be a string or both together.

2.In our SimpleCalc application we have two edit text fields so we will see how to extract data from an Excel file and push the same to our application.

3.First we will create an excel file with some data present in it to test our application. (An Excel file for testing our app is attached here)

4.To extract data from Excel we use “FileInputStream” Class by which we can create/delete and modify a file.

5.Before we get it started some important things to be concentrated on are we have to keep the excel file inside the device and not on the PC because android Robotium doesn’t support the accessing of the files which are stored on to the computer system and not on the Device.

6.So first thing is to push the Excel file to the device. Just go to DDMS tab in eclipse and click on the push icon -> click on browse -> select the Test.xls file that I have provided. The screen shot for this is as shown below:

7.After pushing the Test.xls file to your device or Emulator the next thing what you have to do is add POI jar files to your build path. The link for these jar files can be found at first post.

8.Just create a new folder and name it as POI and add the Jar files to build path after adding them to build path it should look like below:

9.After successfully adding of the poi jar files its time to write program for accessing the data from excel file to our application.

10.The code for accessing data from excel file is as below:


public void test() throws Exception, IOException,
FileNotFoundException,InvalidFormatException {

String cellval1;
String cellval2;

FileInputStream fis= new FileInputStream(Environment.getExternalStorageDire ctory() + “/Test.xls”);

Workbook wb = WorkbookFactory.create(fis); // creates object for workbook Test.xls

Sheet ws = wb.getSheet(“Sheet1”); // opens Sheet1 from workbook Test.xls

int rc = ws.getLastRowNum(); // counts the number of rows which are used

for(int i=1; i<=rc; i++)

Row r = ws.getRow(i); // ponts to the i’th ROW

for (int j=0;j==0;j++){

Cell c = r.getCell(j); // points to the j’th Column
cellval1=c.getStringCellValue(); // gets the data from J’th cell

Cell c1 = r.getCell(j+1); // ponts to the J+1’th column
cellval2=c1.getStringCellValue(); // gets the data from J+1’th cell

solo.enterText(0, cellval1); // pulls data from cellval1 and pushes it on to first editText box

solo.enterText(1, cellval2); // pulls data from cellval2 and pushes it on to second editText box





11.Now when you run the code you will get the output as below:

12.Now as you can see from the above Screen Shot that the values from our excel sheet has been taken properly and after this the test should fail because we have given the second value as a special char and hence the test fails as shown below:

13.As we have finished with Data Driven Testing with Robotium we will now move with our last chapter where in we see what all issues I found while working with Robotium.

7. Issues with Robotium

1. Reporting capability is limited to JUnit Reports in XML format.

2. Writing into excel or text file is a bit clumsy at present.

3. Identifying Excel file for script parameters is manual in nature (Pushing Excel files to the device manually using DDMS).

4. Data whether text or number is taken as a string and fed to the script.

5. No Option of Record and Playback ( Now available 😛 ).

6. Robotium doesn’t work with TestNG suite and Eclipse Kepler at present.

7. Robotium is dependent on Android JUnit for execution control.

Leave a Comment

Top 35 Interview Q/A’s

NOTE: Few of the questions are only asked for freshers.

1. Explain SDLC(Software Development Life Cycle).

2. Explain Waterfall model.

3. Explain Spiral model.

4. Explain V&V model.

5. Explain Prototype model.

6. Explain Hybrid model (spiral + prototype, V&V + prototype).

7. Explain Black box testing.

8. Explain Functional testing.

9. Explain Integration testing and Types of it.

10. Explain System testing.

11. Explain Re-spin in test life cycle.

12. What is a Patch file, Explain.

13. What is Acceptance testing, Explain.

14. What is Hot fix?

15. What is Root cause analysis?

16. Explain Short term release.

17. What is Smoke testing?, When and why we perform Smoke testing?

18. What is Ad-hoc testing?, When and why we perform Ad-hoc testing?

19. What is Exploratory testing?, When and why we perform Exploratory testing?

20. What is Globalization testing?, What are the types? When do we perform Globalization testing? and Why?

21. What is Performance testing? What are the types? When do we perform Performance test? and Why?

22. What is Usability testing?, When do we perform Usability testing and Why?

23. What is Compatibility testing?, When do we perform Compatibility testing and Why?

24. What is Test case, When do we write Test cases and Why?

25. What is Sanity? When do we perform Sanity? and Why?

26. What is Regression testing, What are the types of it. When do we perform Regression testing?

27. Difference between Re-testing and Regression testing?

28. Explain STLC.

29. Explain Test Plan.

30. Explain Defect distribution matrices.

31. Explain Test Efficiency matrices.

32. Explain Test Efficiency.

33. Explain Defect Life Cycle.

34. What is Severity.

34. What is Priority.

35. Explain Test case design techniques and types of it.

Answers for the above questions are as below..

1. Explain SDLC(Software Development Life Cycle).

It is a procedure to develop the software. It is a process of creating or altering systems and the models and methodologies that people use to develop these systems.

2. Explain Waterfall model.


1. Requirements Collection –

  • Done by Business Analysts and Product Analysts
  • Gathering requirements
  • Translates business language into software language

Feasibility Study –

  • Done by software team consisting of project managers, business analysts, architects, finance, HR and Developers but not testers

2. Design –

There are 2 stages in design,

HLD – High Level Design

LLD – Low Level Design

HLD – Gives the architecture of the software product to be developed and is done by architects and senior developers

LLD – Done by senior developers. It describes how each and every feature in the product should work and how every component should work. Here, only the design will be there and not the code.

3. Coding / Programming –

  • Done by all developers – seniors, juniors, freshers
  • This is the process where we start building the software and start writing the code for the product.

4. Testing 

  • Done by test engineers
  • It is the process of checking for all defects and rectifying it.

5. Installation 

Done by installation engineers, To install the product at a client’s place for using after the software has been developed and tested.

For ex, consider the example of a software to be developed and installed at XYZ bank.

6. Maintenance 

Here as the customer uses the product, he finds certain bugs and defects and sends the product back for error correction and bug fixing.

Bug fixing takes place

Minor changes like adding, deleting or modifying any small feature in the software product

100 % testing is not possible –because, the way testers test the product is different from the way customers use the product.

Drawbacks of Waterfall Model :-

In waterfall model, backtracking is not possible i.e, we cannot back and change requirements once the design stage is reached.

Advantages of waterfall model :- Requirements do not change nor does design and code, so we get a stable product.

Applications of waterfall model :-

Used in – developing a simple application

– for short term projects

– whenever we are sure that the requirements will not change

For ex, waterfall model can be used in developing a simple calculator as the functions of addition, subtraction etc and the numbers will not change for a long time.

3. Explain Spiral model.

— Image to be added —

The spiral model is shown in the figure above.

Ra — Requirements analysis of module A. Similarly with Rb, Rc, Rd.

Da – Design of module A. Similarly with Db, Dc, Dd

Ca – Coding of module A. Similarly with Cb, Cc, Cd

Ta – Testing of module A. Similarly with Tb, Tc, Td

In Spiral model, The software product is developed in small modules. Let us consider the image displayed above in developing a software product \\\”X\\\”. \\\”X\\\” is built by integrating modules a,b,c and d.

The module A –Requirements of the module is collected first and then the module is designed. The coding of module A is done after which it is tested for defects and bugs.

The module B – Once module A has been built,We start the same process for module B. But while testing module B, we test for 3 conditions – 1)test module B 2)test integration of module B with A 3)test module A.

The module C –After building module A,B, we start the same process for module C. Here we test for the following conditions – 1) test module C, B, A 2) test for integration of C and B, C and A, A and B.

And thus the cycle continues for different modules. Thus in the above example, module B can be built only after module A has been built correctly and similarly for module C.

Advantages of Spiral Model :-

1)  Requirement changes are allowed.

2)  After we develop one feature / module of the product, then only we can go on to develop the next module of the product.

Drawbacks of Spiral Model :-

1) Traditional model and thus developers only did testing job as well.

2) If any urgent changes to be done in any previously built model, The whole project has to be started from the beginning.

Applications of Spiral Model :-

1)Whenever there is dependency in building the different modules of the software, then we use Spiral Model.

2) Whenever the customer gives the requirements in stages, we develop the product in stages.

4. Explain V&V model.

— Image to be added —

This model came up in order to overcome the drawbacks of waterfall model –Here testing starts from the requirement stage itself.

The V & V model is as shown in the above figure.

1)   In the first stage, the client send the CRS(Customer Requirement Specification) to both developers and testers. The developers translate the CRS to the SRS(Software Requirement Specification).

The testers do the following tests on CRS:

1. Review CRS 

a. Conflicts in the requirements

b. Missing requirements

c. Wrong requirements

2. Write Acceptance Test plan

3. Write Acceptance Test cases

The testing team reviews the CRS and identifies mistakes and defects and send it to the development team for correcting the bugs. The development updates the CRS and continues developing SRS simultaneously.

2 ) In the next stage, the SRS is sent to the testing team for review and the developers start building the HLD(High Level Design) of the product. The testers do the following tests on SRS,

1.  Review SRS against CRS

a. Every CRS is converted to SRS

b. CRS not converted properly to SRS

2. Write System Test plan

3. Write System Test case

The testing team reviews every detail of the SRS if the CRS has been converted properly to SRS.

3 ) In the next stage, the developers start building the LLD(Low Level Design) of the product. The testers do the following tests on HLD,

1. Review HLD

2. Write Integration test plan

3. Write Integration test case

4 ) In the next stage, the developers start with the coding of the product. The testing team carries out the following tasks,

1. Review LLD

2. Write Functional test plan

3. Write Functional Test case

After coding, the developers themselves carry out unit testing or also known as white box testing. Here the developers check each and every line of code and make sure as the code is correct. After whitebox testing, the software product is sent to the testing team which tests the software product and carries out Functional testing, Integration testing, System testing and acceptance testing and finally deliver the product to the client.

Advantages of V&V model:-

1) Testing starts in very early stages of product development which avoids downward flow of defects which in turn reduces lot of rework

2) Testing is involved in every stage of product development

3) Deliverables are parallel/simultaneous –As developers are building SRS, testers are testing CRS and also writing Acceptance Test Plan and Acceptance Test Case and so on. Thus as the developers give the finished product to testing team, the testing team is ready with all the test plans and test cases and thus the project is completed fast.

4) Total investment is less – as there is no downward flow of defects. Thus there is less or no re-work

Drawbacks of V&V model:-

1) Initial investment is more – because right from the beginning testing team is needed

2) More documentation work – because of the test plans and test cases and all other documents

Applications of V&V model:-

1) For long term projects

2) For complex applications

5. Explain Prototype model.

The requirements are collected from the client in a textual format. The prototype of the software product is developed.

The prototype is just an image / picture of the required s/w product. The customer can look at the prototype and if he is not satisfied, then he can request more changes in the requirements.

Prototype testing means developers/ testers are checking if all the components mentioned in requirements are existing or not.

— Image to be added —-

From “REQUIREMENT COLLECTION” to “CUSTOMER REVIEW”, textual format has been converted to image format. It is simply extended requirement collection stage. Actual design starts from “DESIGN” stage.

Prototype development was earlier done by developers. But, now it is done by web designers/content developers. They develop prototype of the product using simple ready-made tools. Prototype is simply an image of the actual product to be developed.

Advantages of Prototype model:-

1) In the beginning itself, we set the expectation of the client.

2) There is clear communication b/w development team and client as to the requirements and the final outcome of the project.

3) Major advantage is –Customer gets the opportunity in the beginning itself to ask for changes in requirements as it is easy to do requirement changes in prototype rather than real applications. Thus costs are less and expectations are met.

Drawbacks of Prototype model:-

1) There is delay in starting the real project

2) To improve the communication, there is an investment needed in building the prototype.

Applications of prototype model:-

We use this model when,

1) Customer is new to the s/w

2) When developers are new to the domain

3) When customer is not clear about his own requirement

There are 2 types of prototype Model,

1. Static Prototype –Entire prototype of the requirement is stored in a word document with explanation and snapshots and instructions on how to go about building the s/w, how the finished product will look like and its working etc.

2. Dynamic Prototype –Similar to a browser, but we can’t enter any information. Only the features are available without entering data. It’s like a dummy page, made out of HTML with tags and links to different pages representing features of the project

6. Explain Hybrid model (spiral + prototype, V&V + prototype).

It combines 2 or more models and modify them as per business requirements.

A) Hybrid model of Spiral and Prototype development models

— Image to be added —

We go for this model when,

1) Whenever there is dependency, we go for this hybrid model

2) When the customer gives requirement in stages, we develop the product in stages using this      hybrid model.

3) When the customer is new to the s/w domain

4) When developers are new to the domain

5) When customer is not clear about his own requirements

B) Hybrid model of V&V and Prototype model

— Image to be added —

We go for this model when,

1) Testing starts from early stages of product development which avoids downward flow of defects, thus reducing re-work.

2) When customer is expecting a very high quality product within stipulated time frame because every stage is tested and developers and testing team work in parallel.

3) When client and developers are both new to the domain

4) When customer is not clear about his own requirements

In this hybrid model, the testing team is involved in testing the prototype.

7. Explain Black box testing.

It is verifying the functionality (behaviour) against requirement specifications.

Advantages of Black box testing:-

  • Well suited and efficient for large code segments.
  • Code Access not required.
  • Clearly separates user\\\’s perspective from the developer\\\’s perspective through visibly defined roles.
  • Large numbers of moderately skilled testers can test the application with no knowledge of implementation, programming language or operating systems.

Disadvantages of Black box testing:-

  • Limited Coverage since only a selected number of test scenarios are actually performed.
  • Inefficient testing, due to the fact that the tester only has limited knowledge about an application.
  • Blind Coverage, since the tester cannot target specific code segments or error prone areas.
  • The test cases are difficult to design.

8. Explain Functional testing.

Also called component testing. Testing each and every component thoroughly (rigorously) against requirement specifications is known as functional testing.

For example, Let us consider an editor application here what we usually test few cases such as editing, deleting, printing etc.

Types of Functional testing:-

1. Positive Functional testing – Testing of the application by applying positive input and also checking the output.

Ex: – Here if we take an application which has one edit field which is made for entering of Mobile number, In this case the tester always takes positive values (lets take it as 9 digit) and test the functionality.

2. Negative Functional testing – Testing of the application by applying some negative scenarios and testing as how the application behaves on wrong inputs. The only thing we test is as weather the app is capable of providing proper error msgs to the user or not.

Ex – Lets take an application which takes input as proper email id, In this case the tester inputs wrong email id\\\’s, wrong inputs and check the application behaviour .

9. Explain Integration testing and Types of it.

Testing the data flow between two features is known as integration testing.

Ex- In Gmail, Entering of valid email and password, New logged in page has to be displayed.

Types of Integration testing:

1. Incremental integration testing –

Take two modules. Check if data flow between the two is working

fine. If it is, then add one more module and test again. Continue like

this. Incrementally add the modules and test the data flow between

the modules.

There are two ways,

a) Top-down Incremental Integration Testing

Incrementally add the modules and test the data flow between the modules. Make sure that the module that we are adding is child of previous one. Child3 is child of child2 and so on.

b) Bottom – up Incremental Integration Testing – 

Testing starts from last child upto parent. Incrementally add the modules and test the data flow between modules. Make sure that the module you are adding is the parent of the previous one.

2. Non – incremental Integration Testing:-

We use this method when,

a) When data flow is very complex

b) When it is difficult to identify who is parent and who is child.

It is also called Big – Bang method.

Combine all the modules at a shot and start testing the data flow between the modules. The disadvantage of this is that, a) We may miss to test some of the  interfaces  b)  Root cause analysis of the defect is difficult identifying the bug where it came from is a problem. We don’t know the origin of the bug.

10. Explain System testing.

It is end-to-end testing wherein testing environment is similar to the production environment.

End – to – end testing:-

Here, we navigate through all the features of the software and test if the end business / end feature works. We just test the end feature and don’t check for data flow or do functional testing and all.

We start System Testing

a) When the minimum number of features are ready  b) basic functionality of all the modules must be working c) testing environment should be similar to production environment

11. Explain Re-spin in test life cycle.

When the first build comes in, immediately we find a bug and send it immediately to the development-team. Thus, immediately we find a bug within a cycle. If another build comes within a cycle where the bug is fixed, then we call it as Re-spin.

We find Re-spin –When the test engineer finds blocker defects / critical defects. For ex, if the login feature itself is not working in gmail, then the test engineer cannot continue with his testing and it has to be fixed immediately – thus re-spin comes into picture.

12. What is a Patch file, Explain.

Patch – is a piece of software which has only modified programs.

We get patch files whenever there is a Issue in a build and the fix for that issue will not affect other modules of the software. The patch file will recover only that particular affected area, Hence there is no need of a new build.

13. What is Acceptance testing, Explain.

Acceptance Testing can be defined as – end-to-end testing done by engineers sitting in customer’s place. Here, they take real time scenarios and check whether the software works or not. Here also, we are able to take real time business scenarios because the end-users know how the business flow works.

We are getting more and more builds for Acceptance Testing means,

  1. The product quality which is delivered to customers is not good. Development and testing both are not good.
  2. After receiving the s/w, customer is getting more and more ideas, so he is asking for more and more changes
  3. The requirement which was given in the beginning is not clear.

Acceptance testing can be performed as per below cases:

Case 1: The developed and tested product will be given to the customer say for example \\\”Sony\\\” is making a software for \\\”Honda\\\”, In this case \\\”Sony\\\” will send/share the final product to \\\”Honda\\\”. Here \\\”Honda\\\” company will be having few test engineers who will perform Acceptance testing and share the results to \\\”Sony\\\”.

Case 2: Here the product will be tested in the production side only i.e., as per our example \\\”Sony\\\”. In this case \\\”Honda\\\” will send few of their test engineers to test @ the production place and produce the results.

Case 3: Sometimes there will be no test engineers available at the customers place so at this time the customer asks the production side as to allocate few test engineers for Acceptance testing and these guys has to go to the customers place and test the build and generate the test results. And also there is a possibility as customer side if they don\\\’t have test engineers they will give the build or product to their customers or end users to test and generate the results.

Acceptance testing will be done after System testing is done.

The actual test flow will be Functional testing >> Integration testing >> System testing >> Acceptance testing.

14. What is Hot fix?

In production environment, whenever the client finds critical bugs – developers fix the bugs –small team of test engineers test it – reinstall the software –client starts using the new software. This entire process is known as Hot fix. It takes approximately few hours to 1 day.

For example,               If the login feature itself is not working at the production environment, then the client immediately sends it for fixing which is done asap.

15. What is Root Cause Analysis(RCA)?

The 5-Why’s and other RCA methods of “causal mapping” are typically illustrated in visual form as cause-effect graphs, with the Fishbone Diagram, or Ishikawa diagram. Taking into account a range of causal factors—from processes to people to materials and equipment—they begin with a problem and work back to its causes (or vice versa, as in the image below), generally looking something like this:

16. Explain Short term release.

Whenever there is a quick fix or any impotent enhancement to be done the dev team will release a new build within one cycle. This is called as Short term release and this release has to be done as soon as possible. Time duration for these types of releases will be less.

17. What is Smoke / Skim testing?, When and why we perform Smoke testing?

Testing the basic or critical features of an application before doing thorough testing or rigorous testing is called as smoke testing.

It is also called Build Verification Testing – because we check whether the build is broken or not.

Whenever a new build comes in, we always start with smoke testing, because for every new build –there might be some changes which might have broken a major feature ( fixing the bug or adding a new feature could have affected a major portion of the original software).

In smoke testing, we do only positive testing – i.e, we enter only valid data and not invalid data.

Why we do Smoke testing ?

  • Just to ensure that product is testable
  • Do smoke testing in the beginning – catch bugs in basic features –send it to development team so that development team will have sufficient time to fix it.
  • Just to ensure that product is installed properly.

In early stages of product development, doing smoke testing fetches more number of bugs. But, in later stages of product development, if you do smoke testing –the number of bugs that you are going to catch in smoke testing will be very less. Thus, gradually the effort spent on smoke testing is less.

18. What is Ad-hoc testing?, When and why we perform Ad-hoc testing?

Testing the application randomly is called Ad-hoc testing. Ad-hoc testing is also called as Monkey testing / Gorilla testing.

Why we do Ad-hoc testing ?

1) End users use the application randomly and he may see a defect, but professional test engineer uses the application systematically  so he might not find the same defect. In order to avoid this scenario, Test Engineer should test the application randomly (i.e., behave like end user and test).

2) Development team looks at the requirements and build the product. Testing Team also look at the requirements and do the testing. By this method, Testing Team may not catch many bugs. They think everything works fine. In order to avoid this, we do random testing behaving like end-users.

3) Ad-hoc testing is a testing where we don\\\’t follow the requirements (we just randomly check the application). Since we don’t follow requirements, we don’t write test cases.

4) To some how break the product. To find more number of issues.

When to do Ad-Hoc testing ?

1) Whenever we are free, we do Ad-hoc testing, i.e., dev\\\’s develop the app and give it to testing team. If testing team is given 15 days for Test Cases execution in that he spend 12 days doing it and another 3 days he does ad-hoc testing. We must always do ad-hoc testing in the last because we always 1st concentrate on customer satisfaction.

19. What is Exploratory testing?, When and why we perform Exploratory testing?

Exploring the application, As how it works, what are the flows of the application, what all features it has, etc. and we write test cases based on it.

We perform Exploratory testing when we do not have requirements specifications for a project.

The reason why we perform exploratory testing, is as we will be not having requirements specification and some how we  have to write the test cases.

20. What is Globalization testing?, What are the types? When do we perform Globalization testing? and Why?

Developing the application for multiple languages is called globalization and testing the application which is developed for multiple languages is called globalization testing.

There are 2 types of globalization testing,

  • Internationalization Testing ( I18N testing )
  • Localization Testing ( L10N testing )


Internationalization Testing ( I18N testing ) – Checking the content is in right language and at right place is called as Internationalization testing. The name I18N came as there are 18 letters in between I and N. Here the imp thing we test is as the meaning of the text should not change and also the alignment is not changed cos of the language change.

Localization Testing ( L10N testing )- Format testing is nothing but Localization testing (OR) Testing done for format specification according to  region / country is called L10N testing.

The different format testing we do in L10N testing,

a) Currency Format testing

Here, we do not worry about the functionality of the format ( like $ is converted to Rs or not ). We only test whether the $ should be in the first or the last.

Ex : 100$, $100, Rs100. The standard should be as per country standards.

b) Date Format testing

Here, check whether the date format is according to its country format. This is also L10N testing.

Ex : In US, date format is : MM – DD – YY

In India, date format is : DD – MM – YYYY

c) PinCode Format testing

There are countries having Pincode with characters like AB100. Here,

Checking for the format in pincode is L10N testing.

Checking whether AB is translated to Chinese is I18N testing.

d) Image Format testing

In image – only name on the image can be changed –the image cannot be changed. Thus we must have multiple images depending on the country. When we click on Ukraine, it goes to Ukraine server, takes the contents and also selects Ukrainian image and thus contents are displayed in Ukraine.

21. What is Performance testing? What are the types? When do we perform Performance test? and Why?

Testing the stability and response time of an application by applying load is called as Performance testing.

There are 4 types in performance testing:-

1. Load testing – Testing the stability and response time by applying load which is equal or less than designed number of users.

2. Stress testing – Testing the stability and response time by applying load which is more than designed number of users.

3. Soak testing – Testing the stability and response time by applying load continuously for particular period of time.

4.Volume testing –  Testing the stability and response time of an application while processing huge amount of data.

Whenever there is a testing of hybrid application is going on, Performance testing is a must.

The reason why we need to perform this testing is to make the application more stable and to make sure the application is not broken due to more load or stress.

22. What is Usability testing?, When do we perform Usability testing and Why?

Testing the user friendliness of an application is called Usability testing.

Given below are some of the parameters we look into for testing. In this most of them are not measurable,

  1. Speed
  2. Help
  3. Navigation should be simple
  4. Compatibility
  5. Look & feel
  6. Features
  7. Location of components

1. Speed – How speed the application reacts to the user inputs. It should be so quick as user must not feel any lag in it.

2. Help – How good is the help part in the application is described. By reading the Help part the user has to understand about the whole application and its functionality.

3. navigation should be simple – Lets take an example of any shopping website, Here if the user wants to buy a product it should has to be purchased in very few clicks.

4. Compatibility – Lets take an example, as one software is built for windows 7 it should has to work in windows 8 too. There must be forward compatibility. If you take example of android then if an app is built for Gingerbread then it should work in Lollipop too.

5. Look and Feel – No mater which application you develop Look and feel does matters a lot. The application should be such that it should be pleasant looking [ suppose if we have red color text in yellow background, definitely we don’t feel like using it ] and make a feel to the end-user to use it.

6. Features – The application should provide all sorts of features which is necessary.

7. Location of components – This also plays an important role. For example, Lets take an example of Google playstore application, Here search icon is always on the top of every screen/page that the user opens. So this makes the user easy to search any data whenever he wishes to.

Usability testing can be performed any time, But mainly it will be concentrated when we get a new build or on the arrival of First build.

The main reason why we perform this testing is to make sure the application is user-friendly or not.

23. What is Compatibility testing?, When do we perform Compatibility testing and Why?

Testing the functionality of an application in different software and hardware environment is called Compatibility testing.

We perform Compatibility testing when we have a software which is built for different platforms. Lets take an example of rhbroms website, the page has to be loaded with all sorts of browsers available (Ex: Chrome, FireFox, IE, Opera etc..). And also the webpage has to be displayed in mobile phones too. The website has to be designed in such a way that it should be compatible with all browsers and systems.

The main reason why we perform compatibility testing is to make sure that software is working fine in all sort of platforms.

24. What is Test case, When do we write Test cases and Why?

Test case is a document which covers all possible scenarios to test all the feature(s).

A test case is a document, which has a set of test data, preconditions, expected results and postconditions, developed for a particular test scenario in order to verify compliance against a specific requirement.

In other words you can say as its a documentation which is written by using test scenarios. Conversion of test scenarios into a document which contains test steps to make test engineer easy for execution.

We write test cases when customer gives requirements – developer start developing and they say they need about 4 months to develop this product –during this time, testing team start writing test cases –once it is done, they send it to test lead who reviews it and adds some more scenarios –developers finish developing the product and the product is given for testing –the test engineer then looks at the test cases and starts testing the product –the test engineer never looks at the requirements while testing the product –thus testing is consistent and does not depend on the mood and quality of the test engineer.

The main reason to write test cases is –

  • To have better test coverage –cover all possible scenarios and document it, so that we need not remember all the scenarios
  • To have consistency in test case execution –seeing the test case and testing the product
  • To avoid training every new engineer on the product –when an engineer leaves, he leaves with lot of knowledge and scenarios. Those scenarios should be documented, so that new engineer can test with the given scenarios and also write new scenarios.
  • To depend on process rather than on a person.

25. What is Sanity? When do we perform Sanity? and Why?

Sanity testing follows narrow and deep approach with detailed testing of some limited features.

For more please refer to answer 17. As in my opinion both smoke and sanity are one and the same. Just change is in the definition.

26. What is Regression testing, What are the types of it. When do we perform Regression testing?

Testing the unchanged features to make sure that it is not broken because of the changes (changes means – addition, modification, deletion or defect fixing).

When the development team gives a build, chances are there they would have done some changes. That change might affect unchanged features. So, Testing the unchanged features to make sure that it is not broken because of the changes is called Regression Testing.

Types of Regression testing –

  1. Unit Regression Testing
  2. Regional Regression Testing
  3. Full Regression Testing

1. Unit Regression Testing – 

Testing only the modified features is called Unit Regression Testing. Lets take one example as We are getting one new build and we know that there is a bug fix and that bug fix is not going to affect any other existing modules, So at this time we go for unit testing and just check the fixed issue and not related modules. Hence the name Unit Regression testing.

2. Regional Regression Testing –

Testing the changes and impact regions is called Regional Regression Testing. Here we not only test the fixed bug but we will also test few regional modules too, to make sure as they are not affected cos of the bug fix. Here the imp thing to notice is the test eng has to be well versed with the software so that he will know which all regional modules might get affected cos of the fixed bug.

3. Full Regression Testing –

Testing the changes and all the remaining features is called Full Regression Testing. He no matter which issue/bug has been fixed we have to test all the remaining modules too, to make sure as the all remaining features/modules are not crashed cos of a build containing more bug fixes.

We do full regression testing when changes are more in the build. mostly on the core part of the application.

27. Difference between Re-testing and Regression testing?

Re-Testing –Developer fixes the bug(or makes some changes) and gives the product for testing. We are testing only the fixed bug(or changed areas) i.e, we are testing only the defect fixes. We are re-validating the defect.

Regression – go through answer 26.

28. Explain STLC.

Testing itself has many phases i.e is called as STLC(Software Test Life Cycle).

STLC is a part of SDLC. The flow of STLC is as below:-

1. Requirements

2. Write Test Plan

3. Write Test Case

3a. Identify all possible test scenarios

3b. Write test case

3c. Review test case

3d. Fix review comments

4. Traceability matrix

5. Test execution

6. Defect tracking

7. Prepare Test Execution report

8. Retrospect Meeting.

Explanation for the above is given below,

1. Requirements – This is the first phase, Here Collection of requirements is done, Usually done by BA(Business Analyst)

2. Test Plan- Is a document which derives all future activities of the project. All future testing activities is planned and put into a document and this document is known as Test Plan. It contains –number of engineers needed for the project, who should test which feature, how the defects must be communicated to the development team, when we should start and finish writing test cases, executing test cases, what are the types of testing we use to test for the application etc.

3. Write test case – We write test cases for each feature. These test cases are reviewed, and after all mistakes are corrected and once the test cases are approved – then they are stored in the test case repository.

4. Traceability Matrix – It is a document which ensures that every requirement has a test case. Test cases are written by looking at the requirements and test cases are executed by looking at the test cases. If any requirement is missed i.e, test cases are not written for a particular requirement, then that particular feature is not tested which may have some bugs. Just to ensure that all the requirements are converted, traceability matrix is written.

5. Test Execution – After completion of writing the Test Cases based on given requirements, Its time to execute them. Test Engineers uses the already written Test Cases and execute them. Test Cases will be divided and allocated to each test engineer.

6. Defect tracking – Any bug found by the testing team is sent to the development team by using some tool (Ex: Bugzilla). This bug has to be verified by the testing team if it has been fixed by the developers or not.

7. Prepare test execution report – Sent to the customer –Contains a list of bugs(major, minor and critical), summary of test pass, fail etc and when this is sent,according to the customer – the project is over.

Test Execution Report is prepared after every test cycle and sent to dev team, testing team, management team and customer (depends if it is a fixed bid project or time & material bid project).

The last Test execution report of the last test cycle is always sent to the customer. And this means that the project is over according to the customer.

8. Retrospect Meeting – (also called Post Mortem Meeting / Project Closure Meeting) The Test Manager calls everyone in the testing team for a meeting and asks them for a list of mistakes and achievements in the project.

This is done by test lead or test manager. Here, the manager documents this retrospect meeting and stores it in QMS (Quality Management System). It is a folder, where inside this folder, there is another folder called Retrospect folder and here this excel sheet document is stored. When we get new project, while we write the test plan we will open this retrospect file and will try and implement the good practices and correct the mistakes.

29. Explain Test Plan.

Test plan is a document which drives all future testing activities.

Test plan is prepared by Test manager(20%), Test Engineer(20%) and by Test Lead(60%).

There are 15 sections in a test plan.

1. Objective

2. Scope

3. Approach

4. Testing Methodologies

5. Assumptions

6. Risks

7. Backup plan

8. Schedule

9. Test Automation

10. Test Environment

11. Defect tracking

12. Test Stop criteria

13. Entry and Exit criteria

14. Deliverables

15. Roles and Responsibilities

16. Templates

1. Objective – It gives the aim of preparing test plan i.e, why are we preparing this test plan.

2. Scope – In the planing stage, we decide which feature to test and which not to test due to the limited time available for the project.

3. Approach – 

The way we go about testing the product in future,

a) By writing high level scenarios

b) By writing flow graphs

a) By writing high level scenarios – For example, if we are testing here we will write the high level scenarios as below:-

1. Open

2. Login to any account and check whether mail is being sent to desired email address or no.

b) By writing flow graphs –

We write flow graphs because of the following advantages,

i. Merging is easy

ii. Coverage is easy

Flow graphs are written because writing high level scenarios is time consuming.

4. Testing Methodologies

Depending upon the application, we decide what type of testing we do for the various features of the application. We should also define and describe each type of testing we mention in the testing methodologies so that everybody (dev team, management, testing team) can understand, because testing terminologies are not universal.

For example, we have to test, we do the following types of testing,

Smoke testing, Functional testing, Integration testing, System testing, Adhoc testing Compatibility testing, Regression testing, Globalization testing, Accessibility testing, Usability testing and Performance testing.

For standalone applications, like Skype, we do the following types of testing,

Smoke testing, Functional testing, Integration testing, System testing, Adhoc testing Compatibility testing, Regression testing, Globalization testing, Accessibility testing, Usability testing, Reliability testing, Recovery testing and Installation / Uninstallation  testing.

5. Assumptions –When writing test plans, certain assumptions would be made like technology, resources etc.

6. Risks – If the assumptions fail, risks are involved. Like if any shortage of resources happens what action can be taken and all are to be considered in this phase.

7. Backup plan –To overcome the risks, a contingency plan has to be made. At-least to reduce the percentage from 100% to 20%.

In the project, the assumption we have made is that all the 3 test engineers will be there till the completion of the project and each are assigned modules A, B, C respectively. The risk is one of the engineers may leave the project mid-way.

Thus, the mitigation plan would be to allocate a primary and secondary owner to each feature. Thus,one engineer quits –the secondary owner takes over that particular feature and helps the new engineer to understand their respective modules.

Always assumptions, risks, mitigation plan are specific to the project.

The different types of risks involved are,

Ø Resource point of view

Ø Technical point of view

Ø Customer point of view

8. Schedule –  This section contains –When exactly each activity should start and end? Exact date should be mentioned and for every activity, date will be specified.

9. Test Automation – 

Here we have to check the below –

1. Features to be automated – Which all features can be automated will be decided here.

2. Features not to be automated – Which all features which can be performed only by manual methods are written here.

3. Which automation tool – Here we decide as which tool can be used for the particular project, Based on the project we decide the automation tool, For Ex: If it is a web based project then we choose selenium. Or if it is an android based application we can go for Robotium or Monkeyrunner.

10. Test Environment – Here we decide the Hardware and Software part, As what all the Hardware / Software has to be given to the test engineer to test the product. Particular to software part which software tool has to be used to deploy the project to the device has to be decided.

11. Defect tracking – In this section, we mention – How to communicate the defects found during testing to the development team and also how development team should respond to it. We should also mention the priority of the defect –high, medium, low.

Defect tracking tool – We mention the name of the tool we will be using to track the defects.

12. Test Stop criteria – We decide to stop the project when – 1. The product is good. 2. The product is Bad.

13. Entry and Exit criteria – 

Entry criteria comes to picture once the following holds good –

A) Test cases should be ready.

B) Product should be installed with proper test environment.

C) Test data should be ready.

D) Resources should be available.

Exit criteria comes to picture once the following holds good –

A) Based on %age test execution.

B) Based on %age test pass.

C) Based on severity.

The Entry and Exit criteria is checked for each and every stage like Functional, Integration, System testing.

14. Deliverables – 

It is the output from the testing team. It contains what we will deliver to the customer at the end of the project. It has the following sections,

14.1 Test Plan

14.2 Test Cases

14.3 Test Scripts

14.4 Traceability Matrix

14.5 Defect Report

14.6 Test Execution Report

14.7 Graphs and Metrics

14.8 Release Note

15. Roles and Responsibilities –  

When a Big project comes, it’s the Test Manager who writes the test plan. If there are 3 small projects, then Test Manager allocates each project to each Test lead. The Test lead writes the test plan for the project which he is allocated.

Usually the below happens –>>

* Test Manager

Ø Writes or reviews test plan

Ø Interacts with customer, development team and management

Ø Sign off release note

Ø Handle issues and escalations

Ø ….

Ø ….

Ø ….


* Test Lead

Ø Writes or reviews test plan

Ø Interacts with development team and customers

Ø Allocates work to test engineers and ensure that they are completing the work within the schedule

Ø Consolidate reports sent by Test Engineers and communicate it to development team, customers (if it is a time&material project) and management

Ø …

Ø …

Ø …


* Test Engineer 1

Ø Review test plan

Ø Write test cases for trend analysis

Ø Asset survey

Ø Write traceability matrix

Ø Review test cases written for sales and purchase modules

Ø Execute test cases written for trend analysis, asset survey, registration (old module developed in previous release. Adding trend analysis and asset survey has affected. Old module has been affected. So do regression testing)

Ø Perform compatibility testing using Internet Explorer, Mozilla Firefox and Google Chrome in  Windows XP and Windows Vista

Ø Prepare test execution report and communicate it to Test lead.

Ø ….

Ø ….

Ø …


* Test Engineer 2

Ø Set up and install the product

Ø Identify test cases to be automated

Ø Automate identified test cases using QTP

Ø Execute and maintain automation scripts

Ø …

Ø …

16. Templates –  

This section contains all the templates for the documents which will be used in the project. Only these templates will be used by all the test engineers in the project so as to provide uniformity to the entire project. The various documents which will be covered in the Template section are,

· Test Case

· Traceability Matrix

· Test Execution Report

· Defect Report

· Test Case Review Template

· …

· …

· …


To be Continued …

Leave a Comment

Python automation

Python for automation using dtmilano’s androidViewClient


1. What is python?
2. What is dtmilano’s android ViewClient?
2a. How to install dtmilano’s android ViewClient?
3. What all methods present in android viewclient?
4. How to import and use android viewclient in our project?
5. How do I automate android native/3rd party apps using android viewclient?
6. How to take screen shots using viewclient?
7. How to handle files using file library?

Let us begin the journey, I hope this one wont be boring

1. What is Python?

Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language.
It was created by Guido van Rossum during 1985- 1990. Like Perl, Python source code is also available under the GNU General Public License (GPL).

2. What is Dtmilano’s android viewclient?

– AndroidViewClient is a 100% pure python library and tools that simplifies test script creation
and android test automation, providing higher level operations and the ability of obtaining the tree of Views present at any
given moment on the device or emulator screen and perform operations on it.

As it’s 100% pure python it doesn’t require monkeyrunner, jython or any interpreter other than python.

2a. How to install Dtmilano’s android ViewClient?
  1. Install Python from
  2. Now download dtmilano’s .egg file from
  3. Once it is done rename the downloaded file to .zip format and after that extract it to C:\Python27\Lib\site-packages.
  4. The easiest method to install this is to use the command “easy_install”. If you don’t have easy_install installed, install the package python-setuptools(
  5. Once its done setup environment variable to C:\Python27\Scripts and after that run easy_install <path of downloaded dtmilano’s .egg file> and you are good to go.

3. What all methods present in viewclient?

– Some of the most used methods I have listed below –

'TRAVERSE_CIT', 'TRAVERSE_CITB', 'TRAVERSE_CITC', 'TRAVERSE_CITCD', 'TRAVERSE_CITCDS', 'TRAVERSE_CITG', 'TRAVERSE_CITPS', 'TRAVERSE_CITUI', 'TRAVERSE_S', '_ViewClient__findViewWithAttributeInTree', '_ViewClient__findViewWithAttributeInTreeOrRaise', '_ViewClient__findViewWithAttributeInTreeThatMatches', '_ViewClient__findViewsWithAttributeInTree', '_ViewClient__getFocusedWindowPosition', '_ViewClient__hammingDistance', '_ViewClient__levenshteinDistance', '_ViewClient__mapSerialNo', '_ViewClient__obtainAdbPath', '_ViewClient__obtainDeviceSerialNumber', '_ViewClient__parseTree', '_ViewClient__parseTreeFromUiAutomatorDump', '_ViewClient__pickleable', '_ViewClient__splitAttrs', '_ViewClient__traverse', '__del__', '__doc__', '__init__', '__module__', 'assertServiceResponse', 'connectToDeviceOrExit', 'distance', 'distanceTo', 'dump', 'excerpt', 'findViewById', 'findViewByIdOrRaise', 'findViewByTag', 'findViewByTagOrRaise', 'findViewWithAttribute', 'findViewWithAttributeOrRaise', 'findViewWithAttributeThatMatches', 'findViewWithContentDescription', 'findViewWithContentDescriptionOrRaise', 'findViewWithText', 'findViewWithTextOrRaise', 'findViewsContainingPoint', 'findViewsWithAttribute', 'getRoot', 'getSdkVersion', 'getViewIds', 'getViewsById', 'hammingDistance', 'imageDirectory', 'installPackage', 'isKeyboardShown', 'levenshteinDistance', 'list', 'longTouch', 'serviceResponse', 'setAlarm', 'setText', 'setViews', 'setViewsFromUiAutomatorDump', 'sleep', 'swipe', 'touch', 'traverse', 'traverseShowClassIdAndText', 'traverseShowClassIdTextAndBounds', 'traverseShowClassIdTextAndCenter', 'traverseShowClassIdTextAndContentDescription', 'traverseShowClassIdTextAndTag', 'traverseShowClassIdTextAndUniqueId', 'traverseShowClassIdTextContentDescriptionAndScreenshot', 'traverseShowClassIdTextPositionAndSize', 'traverseTakeScreenshot', 'writeImageToFile', 'writeViewImageToFileInDir'

4. How to import and use android viewclient?

– Once you have installed android viewclient next step is to use this in our new project. Below is the code snippit for importingandroid view client –

Created on Dec 19, 2015
@author: ravi h basawa
from import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
vc = ViewClient(device=device, serialno=serialno)

5. How do I automate android native/3rd party apps using android ViewClient?

Pre-conditions in your device:
1. Enable USB debugging.
2. Enable stay awake option.

Pre-conditions in PC:
1. android sdk should be present.
2. connect your testing device. (double check with cmd “adbdevices”)
3. python env. variables are all set.
4. Create a new folder named “Automation” on your desktop.
5. Inside it create a new text file and paste the below givencode and save it as (or whatever you want to give)

Lets start– It is very easy to automate android apps usingandroid ViewClient. Let me teach you a simple code which will open settings application.

NOTE: This program I have written using my Nexus device runningAndroid latest version 6.0; So the below program may give you errors. Please edit the code accordingly.

Created on Dec 19, 2015
@author: ravi h basawa
from import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
vc = ViewClient(device=device, serialno=serialno)

print "################## Settings application test ####################"
print 'TEST : PASS'

Once you write the above code, let us save it as And then we will try to open it using IDLE software which will come pre-bundled with python as shown below:

* To execute our newly written code we gonna press F5.

Explanation on above code —
The first line of code is to import dtmilano’s ViewClient method.
the second line is used to define the devices which you have connected, In my case as I have connected only one device I will not provide serialno,
Going further I will show you as how to connect to two devicesand make them communicate.

6. How to take screen shots using viewclient?

– Now we will take our code to the next level, We gonna open settings app, and then we are going to click on About phoneoption. and also we’ll take screen shot of the device to check as what is inside About phone.

NOTE: Create a folder named “Screenshots” at your current working directory(That is in our case folder named Automation) or else you will get Error saying no folder named “Screenshots” is present.

Created on Dec 19, 2015
@author: ravi h basawa
import re
import sys
import time
import os

from PIL import Image

from import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
vc = ViewClient(device=device, serialno=serialno)

print "################## Settings application test ####################"
vc.dump() ## this is used to refresh the screen.

## below is the for loop used to swipe screen five times. the input swipe command takes 4 args that is X1,Y1,X2,Y2 which can be found using "Pointer location" option present in developer settings.

for i in range(5):'input swipe 651 1307 677 680')
vc.findViewWithText("About phone").touch()##this line will click on About phone option.
print 'About phone option found and clicked'
device.takeSnapshot(reconnect=True).save(os.getcwd()+'\\Screenshots\\'+'OS_version.png') #this line will take screenshot of the device and store it in the folder named Screenshots.
print 'Screenshot taken'
print 'TEST : PASS'

Now when you execute the above code you will see the result as below –

Now let us write a code to check the current android version displayed under settings app is proper or not.

Created on Dec 19, 2015
@author: ravi h basawa

import re
import sys
import time
import os

from PIL import Image

from import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
vc = ViewClient(device=device, serialno=serialno)

print "################## Android OS VERSION TEST ####################"
print 'Settings app opened'
for i in range(5):'input swipe 651 1307 677 680')
vc.findViewWithText("About phone").touch()
print 'About phone option clicked''input swipe 651 1307 677 680')
version = vc.findViewWithText('Android version')
if version:
    vnum = vc.findViewWithText('6.0')
    if vnum:
        print 'Android OS version is 6.0'
        device.takeSnapshot(reconnect=True).save(os.getcwd()+'\\Screenshots\\'+'OS_version.png') #this line will take screenshot of the device and store it in the folder named Screenshots.
        print 'Screenshot taken'
        print 'TEST : PASS''KEYCODE_HOME')
        print 'Incorrect OS version'
        print 'TEST : FAIL'
    print 'Android version string not found'
    print 'TEST : FAIL''KEYCODE_HOME')

In the above code you might be wondring as what does vc.dump() stands for, It is actually refreshes the screen and it makes easier to find required data on the screen. Without vc.dump() method there is 100% guarenty that our script gonna fail.

OK, Now we will wrtie a script which has Python functions in it.

Before this let us learn as what is ‘def’ in Pyhton is all about:

As we all know that we define functions to provide the required functionality. Below are some rules to define a function in Python.
[*] Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).
[*] Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.
[*] function names can be started with a _ or a small letter.
[*] The code block within every function starts with a colon ( and is indented.

Now I will write a simple code to show you as how def works.

Created on Dec 19, 2015
@author: ravi h basawa
def test():
    print 'Hi I am inside a function'

As you can see from the above code, there is a single tab given after the fucntion test():, these are called as indents. Once you start using IDLE for python script writing you will get to know more on these indents.

Just for testing purpose try to write your own functions using IDLE; Once you type as ” def test(): ” and hit ENTER without the qouats you will see a single tab occured. This is how Pyhton works. There are no curly brases in it. But only Indents. If you can handle these indents you are good to go.
And one more thing I forgot to explain you guys, That is you can Indent a region by using the shortcut ctrl+] and Dedent using the shortcut ctrl+[

For now let us write the same code; But this time we will use ‘def’ in it.

Created on Dec 19, 2015
@author: ravi h basawa

import re
import sys
import time
import os

from PIL import Image

from import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
vc = ViewClient(device=device, serialno=serialno)

def os_test():
    print "################## Android OS VERSION TEST ####################"
    print 'Settings app opened'
    for i in range(5):'input swipe 651 1307 677 680')
    vc.findViewWithText("About phone").touch()
    print 'About phone option clicked''input swipe 651 1307 677 680')
    version = vc.findViewWithText('Android version')
    if version:
        vnum = vc.findViewWithText('6.0')
        if vnum:
            print 'Android OS version is 6.0'
            device.takeSnapshot(reconnect=True).save(os.getcwd()+'\\Screenshots\\'+'OS_version.png') #this line will take screenshot of the device and store it in the folder named Screenshots.
            print 'Screenshot taken'
            print 'TEST : PASS'
            print 'Incorrect OS version'
            print 'TEST : FAIL'
        print 'Android version string not found'
        print 'TEST : FAIL''KEYCODE_HOME')

Output of the above code will be as below:

============= RESTART: C:\Users\ravi\Desktop\testing\ =============
################## Android OS VERSION TEST ####################
Settings app opened
About phone option clicked
Android OS version is 6.0
Screenshot taken


About file handling
Before we move to the next, Let me teach you as what is ‘class’ in Python and how do we use it.. Below is the small code consists of a class and one function.

Created on Dec 27, 2015
@author: ravi h basawa

class ctest():
    def test(self, value):
        print 'Hi I am inside a function and passed value as >>' + ' ' + value
c = ctest()

* From the above code we have created a class named ‘ctest’ and a function named ‘test’.
* Once we create a class to create a function we have to give one tab inside the ‘ctest’ class.
* The code ‘c = ctest()’ is creating a object for our class.
* The next line ‘c.test(‘testing’)’ will pass value to our newly created function.

I hope now u have understood as how ‘class’ works in Python from the above code.

Ok, Now let us try to send a message and this time let us use “Class” in the below code –

Created on Jan 10, 2016
@author: ravi h basawa

import os

from import ViewClient
device, serialno = ViewClient.connectToDeviceOrExit()
vc = ViewClient(device=device, serialno=serialno)

fd = open('MsgTest.xls',"a+")

class msg():
    def newmsg(self):
        print 'Opening Message app''am start')
        f = vc.findViewWithText('Frequents')
        if f:
            print 'TEST PASS'
            print 'add button clicked'
            print 'TEST FAIL'
c = msg()

The above code does these jobs –
* Creates a class named ‘msg()’. And inside we have created a new function named ‘newmsg()’.
* This code will open google Messenger app and clicks on the ‘add recipients’ button.
* If the ‘add recipients’ button is clicked, our test case will be passed else it will fail.
* ‘open’ function does the job of creating a new xls file in append mode.
* ‘write’ function does the job of writing the data to the new line inside the appended xls file.
* ‘close’ function is used to close the xls file.

Leave a Comment

About me

Hi, My self Ravi.. Enthusiastic test engineer with excellent exposure in Android Test Automation.  When it comes to this website, I will be writing tutorials on whatever new I learn with respect to development and testing.

Leave a Comment