enabling mobile automation t esting using open source t...

10
Mobile Automation Testing Using Open Source Tools 1 Enabling Mobile Automation Testing using Open Source Tools Prepared by:Indium Software India Ltd Name | Title:Alka Arya | Quality Analyst

Upload: others

Post on 25-Apr-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Mobile Automation Testing Using Open Source Tools

1

Enabling Mobile Automation Testing using Open Source Tools

Prepared by:Indium Software India Ltd

Name | Title:Alka Arya | Quality Analyst

Mobile Automation Testing Using Open Source Tools

2 Introduction

The mobile phone has evolved from communication medium to a multipurpose mobile gadget. Technological

advancements of devices have made the mobile device available in operating systems like Apple iOS, Android and Windows Mobile. For functional end-to-end testing perspective, there are different open source tools available

to write automated tests for iOS and Android mobile devices. Various mobile automation tools differ in their scope and usage depending upon their support for different platforms, nature of workflow, level of integration and programming languages used for preparing automation scripts. Open source mobile automation tools are more preferred not only because they are free but also because they accommodate the support from various dimensions resulting in ever improving quality of the tool. The open source tools which we walk through are NativeDriver, Robotium, MonkeyTalk each with a automation of mobile app and get to know the advantage and disadvantage of all these open source tools.

• NativeDriver is an implementation of the WebDriver API that drives the UI of a native application instead of a web application. WebDriver exposes browser functionality as a clean, object-oriented API, and Google uses it to test web applications on multiple platforms.

• Robotium is an automation framework for android application which fully supports of Android

native and hybrid applications.

• MonkeyTalk is cross-platform and functional testing tool that records and plays back highly

readable and maintainable test scripts for native iOS and Android apps as well as mobile web and

hybrid apps.

The audience will

• Understand

o Choice of open source tools available for Mobile Automation testing

o Effective use of mobile test automation for rapidly changing mobile market requirement..

o Walkthrough of NativeDriver,Robotium and Monkeytalk open source tools.

• Get to see and understand example code snippets for automating Android and iOS devices.

1. NativeDriver

Is an opensource framework written over Selenium-2.0 Webdriver implementation. Selenium is a functional automation tool for web-applications and gives a cross-browser, cross-platform supports. The support for testing native application has enhanced the value of selenium. Nativedriver is used by tester working along with the development team and has access to the source code of the andorid application that needs to be tested. NativeDriver is an implementation of the WebDriver API which drives UI of a native application rather than a web application.

WebDriver do not need to learn another API and can start using NativeDriver immediately. NativeDriver

works on the following versions: Android – usable, iOS - usable and Windows - Experimental and prototype phase.

Native Mobile Apps Test Automation with NativeDriver

NativeDriver can be used to perform automated UI commands in a native application in order to test how the application behaves under various conditions.

Mobile Automation Testing Using Open Source Tools

Indium Software | www.indiumsoft.com

3 A NativeDriver Architecture and Test

Demo on Google Map for Andriod

Mobile Automation Testing Using Open Source Tools

Indium Software | www.indiumsoft.com

4

Advantages of Nativedriver:

• NativeDriver is built on selenium webdriver, so its easy for selenium users to understand. • NativeDriver tests are run as Java unit test. • Framework can be redefined for test case execution and reporting.

• Ant or maven can be used for mobile project management.

Disadvantages of Nativedriver:

• Cannot automate app without source code of the application. • Support to find elements by index is not available, so locating some elements is difficult.

Mobile Automation Testing Using Open Source Tools

Indium Software | www.indiumsoft.com

5 2. Robotium

Robotium is an Android test automation framework that automates native and hybrid applications.

Robotium is easy to write and automate robust black-box test cases. Robotium is used by testers to

write function, system and acceptance test scenarios for multiple Android activities.

Creating a Robotium Automated Test Case

• Download the latest version of Robotium, (3.6 at the time of writing). • Create a new Android application in the IDE. E.g Eclipse for Android development. • Add the Robotium JAR as a reference in project.

A Robotium Test Case to automate Calculator test

Mobile Automation Testing Using Open Source Tools

Indium Software | www.indiumsoft.com

6

Instrumentation Code Sample

Running the Test

Compile the APK containing test automation script and install it on test device, along with the APK under test. APK containing the test logic must be signed with the same certificate. This may not be the case if APK under test comes out of a build system.Once both are installed on a test device, the test is launched from a command prompt via adb:

adb shell am instrument -e class com.jc.robotium.RobotiumExample -w com.jc.robotium/android.test.InstrumentationTestRunner

Mobile Automation Testing Using Open Source Tools

Indium Software | www.indiumsoft.com

7 Advantages of Robotium:

• Source code of the mobile app is not required for automating test. • Elements are easy to identify and work on. • Tests are simple to write and easy to understand. • The environment setup is simple to configure.

Disadvantages of Robotium

• Robotium can only be executed using eclipse IDE. • Robotium is slow in execution. • Normal text typing is not supported in robotium. • Flash and web based application cannot be automated.

3. MonkeyTalk

Monkey Talk is open source Automation tool for Android and ios. Monkey Talk is a simple-to-use tool. It automates

real, functional interactive tests for iOS, Android, Web/HTML5, Hybrid and Flex apps. This open source tool can be

used for simple ‘smoke tests’ or for ‘data-driven test’ suites.

MonkeyTalk Script Execution Steps

MonkeyTalk IDE - desktop app for record/playback/creation of test scripts

MonkeyTalk Agent - library that must be added to app to enable testing

MonkeyTalk scripts - understandable, maintainable test scripts

MonkeyTalk IDE

MonkeyTalk Agent

1. Convert Andriod Project to AspectJ

Mobile Automation Testing Using Open Source Tools

Indium Software | www.indiumsoft.com

8

2. Create a "libs" folder in your Android project..

3. Copy the .jar into the libs folder

4. Right click on MonkeyTalk-agent.jar > AspectJ Tools > Add to Aspectpath.

5.Update your AndroidManifest.xml to include the following two permissions: android.permission.INTERNET android.permission.GET_TASKS

7. Deploy application to an Android device or emulator

MonkeyTalk Test Case Script

Passing variable values through driver script. Value for variables can be passed as arguments in a driver script. The only requirement is that they should be provided in the same order as they are declared. We have two scripts here one is the main code (driven) script and the driver script.

In MonkeyTalk form

# Driven script (test1.mt)

Vars * Define paswords user

Mobile Automation Testing Using Open Source Tools

Indium Software | www.indiumsoft.com

9 Input username EnterText ${user}

Input password EnterText ${pass}

Button LOGIN Tap %thinktime=500

Button LOGOUT Tap %thinktime=3000

The tabular form of driven (test1.mt) script

# Driver Script

Script test1.mt Run Test “mypassword”

Script test1.mt Run Test1 “mypassword1″ %thinktime=3000

Driver script in tabular form

Test Script by using default values:

# default.mt

Vars * Define username=Alka password=test

Input username EnterText ${username}

Input password EnterText ${password}

Button LOGIN Tap %thinktime=3000

Label * Verify “Welcome, ${username}!” %thinktime=3000

Mobile Automation Testing Using Open Source Tools

Indium Software | www.indiumsoft.com

10 Result:

Started Script Playback

Vars * Define username=Alka pw=test

:Input username EnterText Alka

Input password EnterText test

Button LOGIN Tap %thinktime=3000

Label * Verify “Welcome, fred!” %thinktime=3000

Completed Script Playback – OK

Advantages of Monkeytalk

• Works with both simulators and actual devices. • Works with all desktop browsers. • MonkeyTalk uses image-based tools to identify things like buttons, tables and text by looking at the

pixels on the screen. • Object-based scripting produces more readable and maintainable. • MonkeyTalk commands are the same for iOS and Andriod devices. • Use the simple MonkeyTalk command language or powerful JavaScript API • Run tests interactively or from continuous integration environments

Disadvantages of MonkeyTalk

• MonkeyTalk is mainly for Mobile application testing - mostly on emulators, or on limited local devices connected via USB to the PC

• SeeTest offers manual and automation testing on mobile devices - locally (Connected within organization network to PC's via USB)

• Only for Android and iOS • Testing of games is difficult • Embedded web pages cannot be tested by MonkeyTalk.

Conclusion

Mobile Test automation is at nascent stage and is evolving. Mobile automation testing is best way to achieve quick,

precise results to accommodate fast development cycles. Manual testing is time consuming for QAs to perform

testing. It not only takes up endless amount of time, but it also brings about higher human error and lower quality of

testing. Which in turn give rise to higher costs and reduced organizational revenue. Hence it is imperative that

organizations commit to an open source mobile test automation tool that delivers a high quality solution.