Search code examples
androidandroid-layoutandroid-viewrobotiumandroid-scrollview

Robotium cannot getText(string) from textviews that are not visible from very top or very bottom of scrollView


Robotium 4.1 doesn't seem to have any features (that work with ScrollView rather than ListView objects) that scroll to a certain point and then stop. My problem is that I need to receive the text from a TextView object that is not visible from the very top of the scrollView but also not visible from the bottom. The ScrollView object as well as the TextView object are both private in the GUI class of the target package, so receiving the string directly is not an option.

this is my attempt

    solo.waitForText("Start Logging");
    solo.clickOnText("Start Logging");
    solo.waitForText("Performing Throughput Test");

    assertEquals(
            GUIHelperFunctions.isServiceRunning(GlobalVariables.getContext(),
                    GlobalVariables.getSERVICENAME(), true), true);
    boolean inProgress = true;
    while (inProgress == true){
        if(!solo.searchText("Performing Throughput Test",true)){
            inProgress = false;
        }
    }


    String message = solo.getText("Upload Throughput:").getText().toString();

i found that it also fails when you exchange the final line for

    assertTrue(solo.searchText("Upload Throughput:"));

In my project I have recieved the contents of several other TextViews that are also within the LinearLayout which is the direct child of the ScrollView, but all of these were visible from the very top or very bottom.

Has anyone found a way around this problem or a way to stop scrolling of a ScrollView in a certain place?


Solution

  • Try to use:

    assertTrue(solo.waitForText("Upload Throughput:", 1, 20000, true));
    

    before

    String message = solo.getText("Upload Throughput:").getText().toString();