solo.search text()不会滚动可扩展列表

时间:2013-10-31 06:57:35

标签: android scroll robotium

我正在使用robotium来测试我的应用。问题在于solo.searchText函数。在我的应用程序中,我使用expandale listview来显示类别值。在使用robotium进行测试时,我正在交叉检查是否所有类别都存在。我正在使用以下代码。

    boolean ifCategoryLoadingFailed = false; 
    for(String cat: UnitTestHelperSuite.getInstance().categories){              
        if(solo.searchText(cat,1,true)){
            //LogAdapter.verbose(TAG, "***********Found Category::"+ cat);
            UnitTestingFramework.expdata.exportResult("****","Found Category::"+cat,"Success");
            continue;
        }
        else{
            ifCategoryLoadingFailed = true;
            //LogAdapter.verbose(TAG, "***********Failed to Found Category::"+ cat);    
            UnitTestingFramework.expdata.exportResult("****","Found Category::"+cat,"Failed");
            break;
        }
    }

以前工作正常。但现在列表不滚动。所以它只识别可见类别。但它没有进入其他条件。测试在这里停止。如何使其可滚动?请帮我。我坚持这个。

1 个答案:

答案 0 :(得分:1)

根据我的经验,solo在搜索文本时总是向下滚动。它不会向后滚动。如果您的问题是在搜索一个值时滚动到底部引起的,那么解决方法是在调用searchText()之前始终调用solo.scrollListToTop(listIndex)。