Skip to content

Iptv Assist

Learn More from us

Menu
  • HOW TO
  • Firestick
  • Chromecast
  • PC Apps
  • Lg Smart TV
  • IPTV Services
  • Automation Testing
  • Smart TV
  • Software Testing Tools
  • Contact Us
Menu

Getting Started with Robotium – The Most Popular Android Application UI Testing Tool

Posted on March 19, 2023

Best Iptv Service Provider 2023 With 40k+ Channels And 100k+ VOD . 24/7 Suppport . Paypal Supported

Robotium is the android Test Automation framework for testing native and hybrid android applications. It provides a simple API to write UI automation scripts. However, the number of tools are available for testing Android applications, Robotium is the most commonly used Android testing tool.

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

Robotium can be used to write functional, system and user acceptance test cases. Robotium Test cases can be executed in the Android emulator as well as the Android real device.

Recommended IPTV Service Providers

  1. IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
  2. IPTVRESALE – Rating 5/5 ( 200+ Reviews )
  3. IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
  4. IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
  5. IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
  6. IPTVTOPS – Rating 5/5 ( 43 Reviews )

 

Further reading => Beginner’s Guide to Mobile Application Testing

Getting Started with Robotium

What You Will Learn:

  • Getting Started With Robotium
    • Benefits Of Robotium
    • Pre-Requisites
    • Creating A Robotium Project
    • Creating Robotium Class
    • Some Robotium Methods
      • Example Program
      • Sample Code
    • Executing The Robotium Project
    • Conclusion

Getting Started With Robotium

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 the hybrid app.
  • Able to handle multiple Android activities.
  • Less time to write tests as the API is simple.
  • Test cases are Robust, due to runtime binding to UI components
  • Fast test case execution.
  • Integrates easily with Maven and ANT.

Pre-Requisites

#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 the ADT bundle from this page.
  • Extract the ADT bundle zip and put it in a folder.
  • Set ANDROID_HOME to the root of the ADT bundle folder in your Environment.

Creating A Robotium Project

Only a few steps required to create a project,

Step #1) Open Eclipse, contains your android application to be tested.

robotium tutorial-1

Step #2) Right-click on the android project -> Android Tools and click on the new Test project.

Step #3) Give a name for the Test project and click the Next button.

robotium tutorial-2

Step #4) Select The Application under test as the target and click the 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 the Build path and click Configure build path.

Step #8) Switch to libraries tab, click on the “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:

 import com.sasi.attendanceproject.Home; 

#3) New class will inherit properties from ActivityInstrumentationTestCase2 class

 
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

 private Solo solo; 

#5) Create a Constructor for the Test class, as below

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

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

Teardown method is used to close the activity after the test has been completed.

 public void tearDown() throws Exception
 { solo.finishOpenedActivities();
 } 

Some Robotium Methods

#1) assertCurrentActivity (text,Activity)
This method verifies whether the current activity is the activity that is passed as the send parameter.
Syntax

solo.assertCurrentActivity("Current Activity", Home.class);

#2) clickOnButton(text)
This method will click on the button with the specified Text.
Syntax:

solo.clickOnButton("ADMIN");

#3) clickOnButton(int)
This method will click on the button with the specified index.
Syntax:

solo.clickOnButton(2);

#4) waitForText(text)
This method will wait until the text appearing on the activity.
Syntax:

solo.waitForText("Creating New Password");

#5) enterText(int, text)
This method will type the text passed as the second parameter to the specified index edit box.
Syntax:

solo.enterText(0,"test");

#6) clickOnCheckbox(int)
This Method will click on the checkbox with the given index.
Syntax:

solo.clickOnCheckBox(0);

#7) clickOnRadioButton(int)
This Method will click on the Radio button with the given index.
Syntax:

solo.clickOnRadioButton(1);

#8) clickOnImage(int)
This Method will click on the image with the given index.
Syntax:

solo.clickOnImage(1);

#9) clearEditText(int)
This Method will clear the text in the edit box with the given index.
Syntax:

solo.clearEditText(0);

#10) waitForText(text)
This Method will wait until the given text is appearing on the activity.
Syntax:

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 in 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/)

robotium tutorial-5

In the Above figure ID of the element is, btnadmin.

Corresponding Robotium code to locate this button is,

solo.clickOnButton(R.id.btnadmin);
  • Locating Element By Position

robotium tutorial-6

In case, if the 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,

solo.clickOnButton(1);
  • Locating Element By Text

robotium tutorial-7

Even you can click on the button using the text displayed on the button.

Solo.clickOnButton(“ADMIN”);
  • Locating Text box Element

Using a 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

Solo.enterText(0,”Anitha”);
//Username textbox is in 1st position
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

 Solo.clickOnRadioButton(1);
//It will location radio button in the second position. 

Sample Code

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 The 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,

 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 Test cases 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 the Real device.
  • Robotium Can be easily written in the 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.

Recommended reading => 5 Mobile Testing Challenges and Solutions

About the author: This is a guest post by Anitha Eswari. She is currently working as a senior testing engineer with more than three years of extensive experience in web and mobile automation testing. She is having sound knowledge in various automation testing tools including mobile testing tools like Robotium and Appium.

In our next article, we will discuss more on Selendroid Tutorial.

Related

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • IPTV List: Best iptv lista 2023
  • IPTV Premium: Best Premium IPTV Service Provider List And Benefits
  • Nikon IPTV Review: Over 10,000 Live Channels for $12/Month
  • Iptvwings. Com Review: +18000 Live IPTV Channels ,+70000 Movies, +40000 TV show For $15/1 month
  • IPTVUNO Review: More Than 16000 Live TV channels, 55,000 Movies & VOD For $15/Month

Recent Comments

  1. IPTV List: Play lista iptv 2022 - Iptv Assist on Best IPTV Player in 2023 for Watching Live TV
  2. Cola IPTV – Over 18,000 Live Channels for $12/Month - Iptv Assist on FileLinked – How to Install on Firestick/Fire TV and Android Devices
  3. Cola IPTV – Over 18,000 Live Channels for $12/Month - Iptv Assist on 50+ Best IPTV Service Providers for Streaming Live TV 2023
  4. XoomsTV IPTV – Over 11,000 Channels & VOD for Under $13/Month on Best VPN for IPTV in 2023 and How to Install on Firestick/Android
  5. Voodoo Streams IPTV Review – Over 12,000 Channels for $11/Month - Iptv Assist on Dynasty TV IPTV Review – Over 6,000 Channels for $10/Month

Archives

  • March 2023

Categories

  • Activate
  • Agile Testing
  • Alternatives
  • Android
  • APK
  • Apple TV
  • Automation Testing
  • Basics of Software Testing
  • Best Apps
  • Breakfast Hours
  • Bug Defect tracking
  • Career in Software Testing
  • Chromebook
  • Chromecast
  • Cross Platform
  • Database Testing
  • Delete Account
  • Discord
  • Error Code
  • Firestick
  • Gaming
  • General
  • Google TV
  • Hisense Smart TV
  • HOW TO
  • Interview Questions
  • iPhone
  • IPTV
  • IPTV Apps
  • Iptv Service SP
  • IPTV Services
  • JVC Smart TV
  • Kodi
  • Lg Smart TV
  • Manual Testing
  • MI TV
  • Mobile Testing
  • Mod APK
  • newestiptv.com
  • News
  • Nintendo Switch
  • Panasonic Smart TV
  • PC Apps
  • Performance Testing
  • Philips Smart TV
  • PS4
  • PS5
  • Python
  • QA Certifications
  • QA Leadership
  • QA Team Skills
  • Quality Assurance
  • Reddit
  • Reviews
  • Roku
  • Samsung Smart TV
  • Screenshot
  • Selenium Tutorials
  • Sharp Smart TV
  • Skyworth Smart TV
  • Smart TV
  • Soft Skills For Testers
  • Software Testing Templates
  • Software Testing Tools
  • Software Testing Training
  • Sony Smart TV
  • Sports
  • Streaming Apps
  • Streaming Devices
  • Tech News
  • Test Management Tools
  • Test Strategy
  • Testing Best Practices
  • Testing Concepts
  • Testing Methodologies
  • Testing News
  • Testing Skill Improvement
  • Testing Tips and Resources
  • Toshiba Smart TV
  • Tutorials
  • Twitch
  • Types of Testing
  • Uncategorized
  • Vizio Smart TV
  • VPN
  • Web Testing
  • What is
  • Xbox
©2023 Iptv Assist | Design: Newspaperly WordPress Theme