Android UI Testing

Related tags

Testing robotium
Overview

Robotium

User scenario testing for 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.

See Questions & Answers for common Robotium questions and answers.

See Getting Started for instructions and examples on how to create your first Robotium tests.

Join the discussions in the Robotium Developers Group.


NEWS: Robotium 5.6.3 is released!

Robotium 5.6.3 is the fastest, most accurate and stable version of Robotium yet.

New functionality includes: clickInRecyclerView(int itemIndex, int recyclerViewIndex, int id) and Config.sleepDuration, Config.sleepMiniDuration (to adjust the execution speed, lower means faster) and more. See the Javadoc for more information.


Robotium provides the following benefits:

  • Test Android apps, both native and hybrid.
  • Requires minimal knowledge of the application under test.
  • The framework handles multiple Android activities automatically.
  • Minimal time needed to write solid test cases.
  • Readability of test cases is greatly improved, compared to standard instrumentation tests.
  • Test cases are more robust due to the run-time binding to UI components.
  • Fast test case execution.
  • Integrates smoothly with Maven, Gradle or Ant to run tests as part of continuous integration.

Robotium Recorder

  • Check out Robotium Recorder that will allow you to record Robotium test cases in minutes. Now also available for Android Studio!
Comments
  • Strange behaviours on big projects

    Strange behaviours on big projects

    From [email protected] on April 18, 2012 03:18:02

    What steps will reproduce the problem? 1.Create test steps with one intent flagged ACTIVITY_CLEAR_TOP or other flags that Robotium conception does not take into account. 2.Call solo.finishOpenedActivities() What is the expected output? What do you see instead? My test should terminate. Instead, I can get functional exceptions, outOfMemoryExceptions due to activities that are unfrozen while they should no more exist, hanging InstrumentationTestRunner, ... What version of the product are you using? On what operating system? Will crash on any SDK and every version of robotium Please provide any additional information below. This is a conception flaw. I think the problem was raised on issue #219 , and rejected. But the problem does exist. The whole conception of keeping a hard reference upon the "stack" of activities is wrong. Android activity manager is much more complex than a simple stack, and stacking activities into an inner object leaks the robotium tests, and bypasses the application expected functional workflow. When a hard reference is kept upon an activity, you prevent Android from managing activities and garbage collecting objects the way it wants to, then the tested application behaves strangely : OutOfMemory (because you keep reference upon an activity that has reference upon bitmaps that can not be garbagecollected), functional exceptions because finishOpenedActivities() calls finish() on activities that should no more exist (for example when an intent is started with flag ACTIVITY_CLEAR_TOP, or NO_HISTORY), hence implemented activity does not handle this unnatural behaviour. A temporary patch should be to keep a stack of WeakReference within the activity stack, to prevent robotium from leaking the whole application then randomly crashing the instrumentationtestrunner. But I don't get the point of keeping the stack at all... Why should this be necessary in a blackbox test ?

    Robotium is a great framework, but this point of conception really is painful. This problem keeps crashing our Jenkins continuous integration, holding all executors whenever it happens, and forcing us to allocate 256Mo heaps emulators to prevent OutOfMemory ! If I can help in any way, please let me know.

    Original issue: http://code.google.com/p/robotium/issues/detail?id=249

    imported Priority-Medium bug 
    opened by renas 46
  • Extended Edittext issue

    Extended Edittext issue

    From [email protected] on May 01, 2012 07:50:38

    What steps will reproduce the problem? 1. create extended class of EditText, with a popupwindow inside it. 2. add the class programmatical (x2) 3. ArrayList edts = solo.getCurrentEditTexts(); for(int i=0; i<edts.size();i++){ solo.clickOnEditText(i); solo.enterText(i, "12345"); solo.enterText(i, "asdfghjklepoiuytrewq"); } What is the expected output? What do you see instead? that i'd click it, to spawn the popupwindow, and then fill it out with the entertext. Worked for the first edittext, but couldnt click the 2nd, it said, i dont know why? What version of the product are you using? On what operating system? 3.2.1, ubuntu 11.10 Please provide any additional information below. I can attach my code etc. if you want :-)

    Original issue: http://code.google.com/p/robotium/issues/detail?id=256

    imported Priority-Medium bug invalid 
    opened by renas 24
  • Problem with current Activity

    Problem with current Activity

    From [email protected] on March 13, 2013 04:37:24

    Hello,

    I have problem with identifying current activity. My application in test [I'm testing apk file directly] has activity A from which activity B is opened. in setUp method I do "solo = new Solo(getInstrumentation(), getActivity());" and later in test

    solo.clickOnText("Test1"); //Test1 text is in activity A solo.sleep(5000); //now the application should be in activity B solo.assertCurrentActivity("This is not correct screen!", "B"); // this fails

    I tried to check activity using "solo.getCurrentActivity().toString()" and that returns "A" even if app is already in B activity

    I found following issue https://code.google.com/p/robotium/issues/detail?id=179 but the workaround does not work for me this code behaves the same

    "solo = new Solo(getInstrumentation());"

    at the begining of test function getActivity(); later solo.clickOnText("Test1"); //Test1 text is in activity A solo.sleep(5000); //now the application should be in activity B solo.assertCurrentActivity("This is not correct screen!", "B"); // this fails

    I checked the "stack" using the "adb shell dumpsys" and from that it looks like the B is above the A including the flag "nowVisible=true"

    Any idea what I'm doing wrong?

    Robotium 3.6 or 4.0; Android 2.3.3 [SDK 10] The apk file is installed and tested on real device Nexus S with Android version 4.1.2

    Thanks, Vladimir

    Original issue: http://code.google.com/p/robotium/issues/detail?id=416

    imported Priority-Medium bug enhancement 
    opened by renas 23
  • solo.getCurrentActivity() is different than actuall activity

    solo.getCurrentActivity() is different than actuall activity

    From [email protected] on October 24, 2011 06:02:28

    I have a main activity A that automatically starts activities B or C depending on the data in database and then returns the result to activity A's callback 'onActivityResult'

    When I run the robotium test, I do see the activity B or C, but when I output the current activity name via

    Log.d("MyTag", solo.getCurrentActivity().getLocalClassName() );

    it would always show activity A.

    Furthermore, when I try to solo.clickOnButton on a button that's on activity B, I will get a NullPointerException (since robotium thinks it's still on Activity A). But I definitely see the Activity B and the button on the emulator screen and Robotium having opened it.

    Is there a workaround for this?

    Original issue: http://code.google.com/p/robotium/issues/detail?id=179

    imported Priority-Medium bug invalid 
    opened by renas 22
  • When there are item in the listview that time searchText and clickOnText is not working properly.

    When there are item in the listview that time searchText and clickOnText is not working properly.

    From [email protected] on November 25, 2010 06:11:59

    What steps will reproduce the problem? 1.Keep nearly 150 items in the list. 2.Now try to search a text using searchText/clickOntext. 3.Exact issue is while scrolling down some list items are getting skipped because of scrolling. What is the expected output? What do you see instead? Expected: While scrolling there should be exact framing of items so that the all the items are visible to instrumentation.

    Actual: Due to improper scrolling action some items are getting skipped so sometimes it is able to search and sometimes it is failing. What version of the product are you using? On what operating system? Please provide any additional information below. Exact issue is while scrolling down some list items are getting skipped because of scrolling.

    Original issue: http://code.google.com/p/robotium/issues/detail?id=36

    imported Priority-Medium bug 
    opened by renas 22
  • Some basic actions fail

    Some basic actions fail

    From [email protected] on February 07, 2011 14:27:17

    What steps will reproduce the problem? "solo.clickOnButton("Yes");" assert-fails with "Button with the text: Yes is not found!", while the text Yes on a button in a dialog is clearly on screen. Similarly, "solo.clearEditText(0);" assert-fails because "EditText with index 0 is not available!". And the full test I run on Collectionista has up to and about 44 of these kind of failures. This test runs correct on Robotium-1.7.1. Sometimes, these actions will succeed, but in a minority of cases. For example, "solo.clearEditText(0);" will pass, but then the next line "solo.enterText(0, ...);" might fail for the same reason. What is the expected output? What do you see instead? These actions should succeed. What version of the product are you using? On what operating system? Robotium 2.1 but 2.0 also exhibits this. 1.7.1 did not. Please provide any additional information below. I would look into a timing issue (looks a lot like bug #61 ). It could be coincidence but I've seen it only in conjunction with dialogs (i.e. where an activity is visible in the background, but not active).

    The Collectionista Alpha test suite: https://code.launchpad.net/~pjv/collectionista/tests-for-alpha rev. 68

    Original issue: http://code.google.com/p/robotium/issues/detail?id=63

    imported Priority-Medium bug 
    opened by renas 21
  • Not able to click on menu option

    Not able to click on menu option

    From [email protected] on January 31, 2011 21:48:35

    What steps will reproduce the problem? 1.In my contact application->launch the contacts list view. 2.Calling str = "^Create contact$", solo.clickOnMenuItem(str); 3. What is the expected output? What do you see instead? Should be able to click on the menu item What version of the product are you using? On what operating system? Robotium2.1 on froyo Please provide any additional information below. Previously able to click on the menu item in robotium 2.0 and 1.9

    Original issue: http://code.google.com/p/robotium/issues/detail?id=61

    imported Priority-Medium bug 
    opened by renas 21
  • recognize

    recognize

    From [email protected] on January 18, 2012 17:48:00

    What steps will reproduce the problem? 1.When I want to searchText("2"), seems it can't recognize "" 2.Can Robotium recognize chinese word? What is the expected output? What do you see instead? What version of the product are you using? On what operating system? 3.0 xp Please provide any additional information below.

    Original issue: http://code.google.com/p/robotium/issues/detail?id=212

    imported Priority-Medium bug invalid 
    opened by renas 20
  • Testing that an OptionsMenu item is disabled

    Testing that an OptionsMenu item is disabled

    From [email protected] on January 30, 2012 11:52:18

    As far as I can tell, there is presently no way to determine if an OptionsMenu item is enabled or disabled. I thought I'd as a workaround try to use clickOnMenuItem to ensure that the application ignored the "press" of a disabled button, but the test fails when the item is (correctly) disabled.

    junit.framework.AssertionFailedError: The text: Disabled Button is not found! at com.jayway.android.robotium.solo.Clicker.clickOnText(Clicker.java:279) at com.jayway.android.robotium.solo.Clicker.clickOnMenuItem(Clicker.java:200) ...

    If you have any workaround ideas, I'm open to them. Otherwise, please add this feature when you can. Thanks so much!

    Original issue: http://code.google.com/p/robotium/issues/detail?id=220

    imported Priority-Medium bug wontfix 
    opened by renas 19
  • Click on text not working

    Click on text not working

    From [email protected] on October 15, 2010 21:46:13

    I've been using Robotium now quite successfully to run around 30 different solo method calls in various tests. I was using 1.7.1, and tried the new 1.8.0, as well as the suggestions to modify the manifest. Nothing changes this behavior.

    I'm having some trouble coaxing it to click a textview though. It's a nested view structure with a scrollview that has a textview and a bunch of buttons inside.

    I tried solo.clickOnText(".Show.") but Solo responds that it couldn't find the text even though it's clearly there on screen. I even stepped through the test to confirm.

    I tried then using clickOnScreen as a kludge. It clicked on the screen and enabled the buttons; however then, the clickOnButton method exhibited the same behavior.

    By the way, it would be nice if you posted a snapshot of the source to the downloads from now on with each version so I don't have to use git and try to figure out which is the right source version. That way I can try to debug it myself.

    Thanks!

    Original issue: http://code.google.com/p/robotium/issues/detail?id=23

    imported Priority-Medium bug wontfix 
    opened by renas 19
  • Fails with SDK rev. 17

    Fails with SDK rev. 17

    From [email protected] on March 23, 2012 01:45:05

    What steps will reproduce the problem? 1. Update android SDK Tools into rev. 17 2. Run tests with solo What is the expected output? What do you see instead? Test should success like with before update into rev.17. But instead we has: 03-23 08:43:25.540: I/TestRunner(2881): java.lang.NoClassDefFoundError: com.jayway.android.robotium.solo.Solo 03-23 08:43:25.540: I/TestRunner(2881): at ru.infteh.organizer.test.TaskEditActivityTest.tearDown(TaskEditActivityTest.java:75) 03-23 08:43:25.540: I/TestRunner(2881): at junit.framework.TestCase.runBare(TestCase.java:130) 03-23 08:43:25.540: I/TestRunner(2881): at junit.framework.TestResult$1.protect(TestResult.java:106) 03-23 08:43:25.540: I/TestRunner(2881): at junit.framework.TestResult.runProtected(TestResult.java:124) 03-23 08:43:25.540: I/TestRunner(2881): at junit.framework.TestResult.run(TestResult.java:109) 03-23 08:43:25.540: I/TestRunner(2881): at junit.framework.TestCase.run(TestCase.java:118) 03-23 08:43:25.540: I/TestRunner(2881): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) 03-23 08:43:25.540: I/TestRunner(2881): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) 03-23 08:43:25.540: I/TestRunner(2881): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) 03-23 08:43:25.540: I/TestRunner(2881): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) What version of the product are you using? On what operating system? ver 3.1, OS Windows 7, eclipse ide Please provide any additional information below.

    Original issue: http://code.google.com/p/robotium/issues/detail?id=237

    imported Priority-Medium bug 
    opened by renas 18
  • Could not find manifest file within jar

    Could not find manifest file within jar

    I have downloaded jar file and when try to execute jar file, getting maniest error as shown below in image.

    image

    Within console, getting this error

    error: no main manifest attribute, in robotium-solo.jar

    opened by punitmirani30 0
  • Robotium to work with targetSdkVersion 30

    Robotium to work with targetSdkVersion 30

    When I tried to use Robotium with targetSdkVersion 30, the following error appears. error: package android.support.test does not exist import android.support.test.InstrumentationRegistry;

    Please help to resolve this issue.

    opened by anbunathan 1
  • Robotium Recorder : Please install a compatible Android API level (15 or higher)

    Robotium Recorder : Please install a compatible Android API level (15 or higher)

    Trying to run a new robotium test I get this error. Does anyone know how to fix it?

    I've all the APIs needed. (15 and a lot of higher APIs). What am I missing?

    This is part of my gradle file:

    `android { compileSdkVersion 25 buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.centervue.exam"
        minSdkVersion 19
        targetSdkVersion 25
        // DO NOT PUT HERE VERSION NAME, THX. Change the Manifest
    
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    
        ndk {
            moduleName "exam_filter"
            ldLibs "log", "jnigraphics"
        }
        renderscriptTargetApi 18
        renderscriptSupportModeEnabled true
    }
    

    [...]`

    I am testing it on Android API level 28 device. still getting this issue.

    Screenshot

    StackOverflow Link: https://stackoverflow.com/questions/42908481/robotium-please-install-a-compatible-android-api-level-15-or-higher

    opened by erummalik 2
  • assertFalse does not work on Android Oreo 8.1

    assertFalse does not work on Android Oreo 8.1

    The following test works fine on API 22 (Lollipop) to 26 (Oreo 8.0) and also 28 (P). But for some reason it does not work on API 27 (Oreo 8.1).

    1. Open Google Map
    2. Display Toast
    3. assertTrue("toast message");
    4. Close Google Map
    5. Open Google Map
    6. assertFalse("toast message");

    It always fails at 6. Any ideas?

    opened by EQXTFL 1
Android UI Testing

User scenario testing for Android Robotium is an Android test automation framework that has full support for native and hybrid applications. Robotium

null 2.8k Dec 14, 2022
A set of AssertJ helpers geared toward testing Android.

AssertJ Android A set of AssertJ assertions geared toward testing Android. Deprecated The support libraries and play services are developing at a rate

Square 1.6k Jan 3, 2023
Android Unit Testing Framework

Robolectric is the industry-standard unit testing framework for Android. With Robolectric, your tests run in a simulated Android environment inside a

Robolectric 5.6k Jan 3, 2023
Android UI Testing

User scenario testing for Android Robotium is an Android test automation framework that has full support for native and hybrid applications. Robotium

null 2.7k Apr 8, 2021
A sample repo describing best practices for snapshot testing on Android

Road to effective snapshot testing A sample repo describing best practices for snapshot testing on Android. This includes for now: Parameterized Tests

Sergio Sastre Flórez 86 Jan 1, 2023
Testify — Android Screenshot Testing

Testify — Android Screenshot Testing Add screenshots to your Android tests Expand your test coverage by including the View-layer. Testify allows you t

ndtp 43 Dec 24, 2022
A programmer-oriented testing framework for Java.

JUnit 4 JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. For more infor

JUnit 8.4k Jan 9, 2023
A programmer-oriented testing framework for Java.

JUnit 4 JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. For more infor

JUnit 8.4k Dec 28, 2022
Turbine is a small testing library for kotlinx.coroutines Flow.

A small testing library for kotlinx.coroutines Flow

Cash App 1.8k Jan 5, 2023
Fixtures for Kotlin providing generated values for unit testing

A tool to generate well-defined, but essentially random, input following the idea of constrained non-determinism.

Appmattus Limited 191 Dec 21, 2022
Morsa: Jetpack Compose UI Testing Framework

Morsa: Jetpack Compose UI Testing Framework Test library to ease UI testing with Jetpack Compose Purpose This library aims to add some useful wrappers

HyperDevs 10 Dec 3, 2022
Lovely Systems Database Testing

Lovely DB Testing This repository provides opinionated testing helpers for database testing used at Lovely Systems. License This plugin is made availa

Lovely Systems GmbH 1 Feb 23, 2022
Project for testing intern candidate simple level

RickAndMorty-TestTask Тестовый проект 'Гайд по мультфильму Рик и Морти' для практикантов начального и продвинутого уровня. Структура проекта Структура

null 0 Nov 18, 2021
Very simple Morse API text translator. Mainly to do some testing with jitpack, API development etc.

Very simple Morse text translator API. Far from finish or even being reliable. Use for single sentence. Mainly to test github dependency for Android

Piotr Dymala 0 Dec 30, 2021
Snapshot Testing framework for Kotlin.

KotlinSnapshot Snapshot Testing framework for Kotlin. What is this? Snapshot testing is an assertion strategy based on the comparision of the instance

Pedro Gómez 157 Nov 13, 2022
A set of TestRules and ActivityScenarios to facilitate UI Testing under given configurations: FontSizes, Locales

AndroidUiTestingUtils A set of TestRules, ActivityScenarios and utils to facilit

Sergio Sastre Flórez 122 Dec 23, 2022
Android library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests.

Green Coffee Green Coffee is a library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests using the

Mauricio Togneri 227 Nov 21, 2022
null 866 Dec 27, 2022
Linkester is an Android library that aims to help Android developers test their deep links implementation.

Linkester Linkester is an Android library that aims to help Android developers test their deep links implementation. The idea is to have a new launche

Ahmad Melegy 79 Dec 9, 2022