0

Robotium How to click or enter or select a file in Downloads folder on android device to open options as (Gallery, Image Gallery, Photos, etc)

Here is my code:

        String filepath = "/Downloads/";
        File file = new File(filepath +"images.jpeg" );
        Intent intent = new Intent(Intent.ACTION_VIEW);
   intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   intent.setClassName("com.android.providers.downloads.ui", "com.android.providers.downloads.ui.DownloadList");
   getInstrumentation().getContext().startActivity(intent);
   setActivityIntent(intent);
        Solo solo2 = new Solo(getInstrumentation(), getActivity());
   solo2.getCurrentViews();
   assertNotNull(solo2);
   solo2.clickInList(1);
   solo2.sendKey(solo2.ENTER);
   solo2.waitForDialogToOpen(10000);
        solo2.clickInList(1);
        solo2.clickOnButton("Just once");
        ....

I try to run it and get the next error:

"junit.framework.AssertionFailedError: AbsListView is not found!
at com.jayway.android.robotium.solo.Waiter.waitForAndGetView(Waiter.java:501)
at com.jayway.android.robotium.solo.Clicker.clickInList(Clicker.java:450)
at com.jayway.android.robotium.solo.Clicker.clickInList(Clicker.java:430)
at com.jayway.android.robotium.solo.Solo.clickInList(Solo.java:1170)
at com.nsi.mobile.client.autotest.TestPrintQueue.testPrintfromOutside(TestPrintQueue.java:104)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)"

Any ideas?

4 Answers 4

1

Your problem is because the Robotium solo could just use the classes, that you own. Maybe this solution could help for you.

1

With Robotium, you only have access to activities that belong to your application. Gallery, Image Gallery, Photos, ect. launch activities that do not belong to your application.

0

If you want to write tests with pre-installed apps use UIAutomator testing framework from Google: http://developer.android.com/tools/help/uiautomator/index.html

2
  • That might be good information for someone who is just looking into doing the test, but are you sure this actually helps user solve the problem they're facing? Does UIAutomator integrate with Robotium?
    – corsiKa
    Commented Mar 11, 2014 at 17:25
  • 1
    You may easy add uiautomator framework library to test project. So I believe you may use Robotium and UIAutomator together
    – amazpyel
    Commented Mar 12, 2014 at 12:05
0

I've just had this exact problem too.

I'm running the tests on my phone (Nexus 4, 4.4.2) and I realised I got the 'junit.framework.AssertionFailedError: AbsListView is not found!' exception when my phone screen was on but locked. Yes, really.

Unlock phone => bam, test passes again.

1
  • This does not provide an answer to the question
    – amazpyel
    Commented Feb 5, 2015 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.