Showing posts with label Mobile Automation ( iOS / Android). Show all posts
Showing posts with label Mobile Automation ( iOS / Android). Show all posts

Tuesday, February 17, 2015

10 Open Source Mobile Test Automation Tools

Here is a list of top ten open source mobile test automation tools to allow you to automate mobile apps and mobile web. Some open source tools for mobile automation can be used for both Android and iOS as well as Native, Web and Hybrid.
appium-toolAppium(Android and iOS)
Appium is an open-source tool for automating native, mobile web, and hybrid applications on iOS and Android platforms.Native apps are those written using the iOS or Android SDKs.Mobile web apps are web apps accessed using a mobile browser (Appium supports Safari on iOS and Chrome or the built-in ‘Browser’ app on Android). Hybrid apps have a wrapper around a “webview” — a native control that enables interaction with web content. Download Appium



calabash-toolCalabash (Android and iOS)
Calabash is an automated acceptance testing framework for mobile apps. Calabash could be compared to Selenium WebDriver. However, it is important to realize that interacting with a web app from a desktop computer is vastly different than interacting with a native app using a touch screen. Calabash provides APIs that are specialized to native apps running on touch screen devices.Download Calabash



frank-ios-toolFrank (iOS)
Frank allows you to write structured text test/acceptance tests/requirements (using Cucumber) and have them execute against your iOS application. Frank also includes a powerful “app inspector” (called Symbiote) that you can use to get detailed information on your running app. Download Frank



monkeytalk-toolMonkeyTalk (Android and iOS)
MonkeyTalk automates real, functional interactive tests for iOS and Android apps – everything from simple “smoke tests” to sophisticated data-driven test suites. Native, mobile, and hybrid app, real devices or simulators. Download MonkeyTalk



ios-ui-automation-tooliOS UI Automation (iOS)
Use the Automation instrument to automate user interface tests for your iOS app through test scripts that you write. These scripts simulate user actions by calling UI Automation, a JavaScript programming interface that specifies actions to be performed in your app as it runs. During the tests, the system returns log information to you.
When you automate tests of UI interactions, you free critical staff and resources for other work. In this way you minimize procedural errors and shorten the amount of time needed to develop product updates. More information



robotium-toolRobotium (Android)
Robotium is an Android test automation framework that has full support for native and hybrid applications. Robotium makes it easy to write powerful and robust automatic black-box UI tests for Android applications. With the support of Robotium, test case developers can write function, system and user acceptance test scenarios, spanning multiple Android activities. Download Robotium



ios-driver-tooliOS-driver (iOS)
Automate any IOS native, hybrid, or mobile web application using the Selenium / WebDriver API. ios-driver is fully compatible with the Selenium / Webdriver API. IOS automation is therefore as easy as automation for a browser.
ios-driver fully integrates with Selenium Grid so you can reuse your existing web automation infrastructure including your helper and utility classes (i.e. data creation, page objects etc.)
Download iOS-driver



ui-automator-toolUi Automator (Android)
The uiautomator testing framework lets you test your user interface (UI) efficiently by creating automated functional UI testcases that can be run against your app on one or more devices.
The uiautomator API is bundled in the uiautomator.jar file under the /platforms/ directory. The API includes these key classes, interfaces, and exceptions that allow you to capture and manipulate UI components on the target app. More information



kif-toolKeepItFunctional (iOS)
KIF, which stands for Keep It Functional, is an iOS integration test framework. It allows for easy automation of iOS apps by leveraging the accessibility attributes that the OS makes available for those with visual disabilities.
KIF builds and performs the tests using a standard XCTest testing target. Testing is conducted synchronously in the main thread (running the run loop to force the passage of time) allowing for more complex logic and composition. Download KIF



selendroidSelendroid (Android)
Selendroid is a test automation framework which drives off the UI of Android native and hybrid applications (apps) and the mobile web. Tests are written using the Selenium 2 client API.Download Selendroid

Automated Mobile Testing Tools

Automating the testing of mobile applications is especially challenging as mobile devices are less accessible and less open than standard desktop environments or web-based applications. Vendors of automated testing tools usually offer specialized modules or additional tools as part of their products designed for mobile applications. There are also a couple of free open source tools that you can use to automate your mobile application tests.
Commercial

DeviceAnywhere

DeviceAnywhere is available in multiple editions and allows you to test your apps and websites on different devices and automate your mobile tests.
Commercial

Ranorex

Ranorex can be used to automatically test mobile applications on iOS, Android and Windows 8 devices. Ranorex allows you to directly record your tests on your device to build your tests.
Commercial

eggPlant

eggPlant is another test automation tool that also supports various mobile development platforms such as iOS, Android and Windows Mobile/Phone.
Commercial

Silk Mobile

Silk Mobile is a test automation tool for web, iOS, Android, Blackberry and Windows Phone devices, which allows you to build and run your automated tests without having to jailbreak your devices.
Commercial

SeeTest

SeeTest is a test automation tool for iOS, Android, Blackberry and Windows Phone. It allows you to record your tests on real devices and can be used to build cross-platform test automation suites.
Open Source

MonkeyTalk

MonkeyTalk is an open source test automation tool for mobile devices. It can be used to automate real, functional interactive tests for native, mobile, and hybrid iOS and Android apps, everything from simple smoke tests to more complex data-driven test suites.
Open Source

NativeDriver

NativeDriver is an implementation of the WebDriver API which drives of the UI of a native application rather than a web application. The project is working on drivers for Android, iOS and Windows/Windows Phone devices and applications.

OPEN SOURCE! THE TOP 10 IOS AND ANDROID AUTOMATION TOOLS

  • Appium (iOS/Android) is a splendid open source tool used for automation of native and web as well as hybrid apps. What I mean by that is the fact that it is good for automation of apps written on original Android or iOS SDKs (native), web applications that are accessible via a mobile browser (web) and applications that are wrapped around the ‘webview’- the native control feature which enables various interactions with web contents (hybrid).
  • Calabash (iOS/Android) is an acceptance testing automation framework. It may be compared with the famous Selenium Web Driver. Yet every tester has to realize the difference between testing the app on a desktop machine and on a touchscreen devise. Especially when dealing with a native application. Calabash may provide the necessary API full of ‘touchscreening’ experiences.
  • Frank (iOS) actually allows you to write structure text tests as well as acceptance tests and requirements (via Cucumber) and all that fun will be executed against your iOS app. You can also get all the required info about your running app via Frank’s Symbiote, the app inspector in other words.
  • MonkeyTalk (iOS/Android) can automate all possible real and functional interactive tests. Everything from little “Smoke Tests” to the tough data-driven test suits. It does bot real device and simulation tests with native and hybrid as well as mobile apps.
  • iOS UI Automation (for iOS)  This one is an instrument. The one you can use for automating your user interface tests through some written test-scripts.
  • Robotium (Android)  A great tool for both native and hybrid apps. Robotium makes black box testing fairly easier. With it test case developers are free to write function and system as well as user acceptance test scenarios.
  • iOS Driver (iOS)  is capable of complete integration with the Selenium grid. Thus you will have the possibility of reusing the already existing wen automation infrastructure. This also includes the helper as well as the utility cases.
  • UI Automator (Android) This UI Automation framework allows you to test your UI via creation of automated functional test cases. They will be able of running against your app on a single or multiple devices.
  • KeepItFunctional (iOS) KIF is an integration test framework. KIF is building and performing cases with a standard XCTest testing target.
  • Selendroid (Android) is but one more test automation framework. It is driven of the UI of both native and hybrid apps as well as the mobile web. So the tests will be written via Selenium 2 client API.

Wednesday, November 26, 2014

Robotium - Android Application UI Testing Tool

Robotium is the android test automation framework for testing native and hybrid android applications. It provides simple API to write UI automation scripts. However, Number of tools are available for testing android applications, Robotium is the most commonly used Android testing tool.
Robotium can be used to write functional, system and user acceptance testcases. Robotium Testcases can be executed in Android emulator as well as the Android real device.

What is covered in this Robotium Tutorial:

  • Benefits
  • Prerequisites
  • Creating Robotium Project
  • Creating Robotium Class
  • Some Robotium Methods
  • Locating  Elements in Android application
  • Sample Code
  • Executing Robotium Project
Robotium tutorial

Benefits of Robotium

  • Easy to write
  • Simple API (All Methods are available only in Solo Class)
  • Automatic Delays & Timings
  • No need to write code , when navigating from one activity to another activity.
  • Test Android native apps as well as hybrid app.
  • Able to handle multiple android activities.
  • Less time to write tests as the API is simple.
  • Testcases are Robust , due to runtime binding to UI components
  • Fast testcase execution.
  • Integrates easily with Maven and ANT.

Prerequisites

1) Download and Install JAVA
– Download Java from this page.
– Add java libraries to the PATH and set JAVA_HOME to the root of java installation directory in your environment.
2) Download ADT Bundle
  • Download ADT bundle from this page.
  • Extract ADT bundle zip and put it in a folder.
  • Set ANDROID_HOME to the root of ADT bundle folder in your Environment.

Creating a Robotium Project

Only few steps required to create a project,
Step #1: Open eclipse contains your android application to be tested.
(Click on image to enlarge)
robotium tutorial-1
Step #2: Right click on the android project -> Android Tools and click on new Test project.
Step #3: Give name for the Test project and click Next button.
robotium tutorial-2
Step #4: Select The Application under test as the target and click finish button.
robotium tutorial-3
Step #5: Test project will be created in the eclipse workspace.
Step #6: Download Robotium solo jar from here.
Step #7: Right click on the Test project in the workspace Go to Build path and click Configure build path.
Step #8: Switch to libraries tab, click on “Add external jars” option and browse the downloaded Robotium jar file and add it to the libraries and click “OK”.
robotium tutorial-4
Step #9: Robotium Test project is created successfully. Now we can create classes under the project and start writing the test cases.

Creating Robotium Class

#1: Right click on the package under src directory in the Test project, and create a new class.
#2: Import the Main Activity class the Robotium test project.
Syntax:
1
import com.sasi.attendanceproject.Home;
#3: New class will inherit properties from ActivityInstrumentationTestCase2 class
1
2
public class AttendanceTest extends
ActivityInstrumentationTestCase2 <home>
(Note: Here, Home is the activity to be tested in the android application)
#4: Create Instance for Solo class as below
1
private Solo solo;
#5: Create a Constructor for the Test class, as below
1
2
3
public AttendanceTest() {
    super(Home.class);
    // TODO Auto-generated constructor stub
#6: Create setUp and tearDown methods , as below
Setup method is used to Initiate the Instrumentation
1
2
3
4
public void setUp()throws Exception
{
   solo=new Solo(getInstrumentation(), getActivity());
}
Teardown method is used to close the activity after the test has been completed.
1
2
3
public void tearDown() throws Exception
{ solo.finishOpenedActivities();
}

Some Robotium Methods

#1. assertCurrentActivity (text,Activity)
This method verifies whether the current activity is the activity which is passed as the send parameter.
Syntax
1
solo.assertCurrentActivity("Current Activity", Home.class);
#2. clickOnButton(text)
This method will click on the button with the specified Text.
Syntax:
1
solo.clickOnButton("ADMIN");
#3. clickOnButton(int)
This method will click on the button with the specified index.
Syntax:
1
solo.clickOnButton(2);
#4. waitForText(text)
This method will wait until the text appearing on the activity.
Syntax:
1
solo.waitForText("Creating New Password");
#5. enterText(int, text)
This method will type the text passed as the second parameter to the specified index editbox.
Syntax:
1
solo.enterText(0,"test");
#6. clickOnCheckbox(int)
This Method will click on the checkbox with given index.
Syntax:
1
solo.clickOnCheckBox(0);
#7clickOnRadioButton(int)
This Method will click on the Radio button with the given index.
Syntax:
1
solo.clickOnRadioButton(1);
#8. clickOnImage(int)
This Method will click on the image with the given index.
Syntax:
1
solo.clickOnImage(1);
#9. clearEditText(int)
This Method will clear the text in the edit box with the given index.
Syntax:
1
solo.clearEditText(0);
#10. waitForText(text)
This Method will wait until the given text is appearing on the activity.
Syntax:
1
solo.waitForText(“Robotium”);

Example Program

Locating Elements in Android Application

Step – 1
Open Eclipse containing Android Application to be Tested.
Step – 2
Expand the project , Go to res ? Layout folder and double click on the activity XML file, you want to automate. It will open the designed activity on the eclipse editor.
Step – 3
Locating Button Element
Locating Element By ID
Click on the Element , you want to locate. On the right side properties panel, you can find the ID of that element. (ignore @+id/)
(Click on image to enlarge)
robotium tutorial-5
In the Above figure ID of the element is, btnadmin.
Corresponding Robotium code to locate this button is,
1
solo.clickOnButton(R.id.btnadmin);
Locating Element By Position
robotium tutorial-6
In case, if ID is not available then you can locate the element using the order. If the button is in the second position, Then you can locate the button by,
1
solo.clickOnButton(1);
Locating Element By Text
robotium tutorial-7
Even you can click on the button using the text displayed on the button.
1
Solo.clickOnButton(“ADMIN”);
Locating Text box Element 
Using Similar way click on the text box you want to enter data and find the position of the text box from the right side.
robotium tutorial-8
1
2
Solo.enterText(0,”Anitha”);
//Username textbox is in 1st position
1
2
Solo.enterText(1,”test”);  
//Password textbox is in 2nd position
Locating a Radio Button Element
Click on the Radio Button Element , you want to click and find out the position of the radio button.
robotium tutorial-9
1
2
Solo.clickOnRadioButton(1);
//It will location radio button in the second position.

Sample Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.sasi.attendanceproject.test;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.EditText;
 
import com.robotium.solo.By;
import com.robotium.solo.Solo;
import com.robotium.solo.WebElement;
import com.sasi.attendanceproject.Home;
 
public class AttendanceTest extends ActivityInstrumentationTestCase2<Home>{
    private Solo solo;
    public AttendanceTest() {
        super("com.sasi.attendanceproject.Home",Home.class);
        // TODO Auto-generated constructor stub
    }
 
    public void setUp()throws Exception{
        solo=new Solo(getInstrumentation(),getActivity());
    }
    public void testAttendance()throws Exception{
        //solo.assertCurrentActivity("Current Activity", Home.class);
        solo.waitForWebElement(By.id("btnadmin"));
        solo.clickOnButton("ADMIN");
        solo.clickOnButton(0);
        solo.waitForText("Creating New Password");
        solo.enterText(0, "test");
        solo.enterText(1, "test");
        solo.clickOnButton("Okay");
        solo.waitForText("Attendance Login");
        solo.enterText(0, "Anitha");
        solo.enterText(1, "test");
        solo.clickOnButton("Login");
        solo.waitForWebElement(By.id("btnaddnew"));
        solo.clickOnButton("Add New Details");
        solo.waitForText("Enter the Employee Details");
        solo.enterText(0, "Anitha");
        solo.enterText(1, "6");
        solo.enterText(2, "Testing Engineer");
        solo.clickOnRadioButton(1);
        solo.clickOnButton("Okay");
        solo.waitForWebElement(By.id("tvempID"));
        System.out.println(solo.getText(0));
 
    }
    public void tearDown()throws Exception{
        solo.finishOpenedActivities();}}

Executing Robotium Project

From Eclipse:

Right click on the project and select Run As -> Android Junit Test

From Command Prompt:

Step 1:
Cd to your Android Test Project Directory
Step 2:
Run the following command,
1
2
adb shell am instrument -w <<package name of your test
class>>/android.test.InstrumentationTestRunner
robotium tutorial-10

Conclusion

  • Robotium is the most commonly used Android Test automation tool.
  • Robotium Testcases can be executed on Android Emulator as well as the Real device, we don’t need to write any specific configuration code to run Robotium test cases on Real device.
  • Robotium Can be easily written in maven project also, and it can be run through continuous integration tools.
  • Thus, Robotium is very useful in writing easy/simple Android Test automation scripts.