我試圖使用Robotium驗證大型列表的內容,並且由於某種原因,一旦程序到達可見列表的底部,Robotium將開始滾動,並保持滾動狀態,直到它到達列表的底部。有什麼我可以做的,以防止這種情況發生?理想情況下,程序將驗證可見內容,足夠滾動以顯示未驗證內容的一部分,然後一旦驗證完畢,滾動到底部,最終允許測試應用程序驗證列表中的所有內容。停止使用Robotium滾動
這裏是我使用的代碼:
public void testCatalogLinkContent(){
//VERIFY USER IS ON HOMEPAGE
try {
solo.sleep(3000);
assertTrue(solo.searchText(" Apps")) ;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//CLICK ON CATALOG
try{
solo.clickOnText(" Apps");
}catch(Exception e){
e.printStackTrace();
}
//Search for Music in menu
if(solo.searchText(RECOMMENDED)==false){
Log.e(TAG, RECOMMENDED + " Not found!!!");
}else{
Log.i(TAG, RECOMMENDED + " Found");
}
//Search for UAT in menu
if(solo.searchText(UAT)==false){
Log.e(TAG, UAT + " Not found!!!");
}else{
Log.i(TAG, UAT + " Found");
}
//Search for NEW APPS in menu
if(solo.searchText(NEW)==false){
Log.e(TAG, NEW + " Not found!!!");
}else{
Log.i(TAG, NEW + " Found");
}
//Search for TOP SELLERS in menu
if(solo.searchText(TOPSELLER)==false){
Log.e(TAG, TOPSELLER + " Not found!!!");
}else{
Log.i(TAG, TOPSELLER + " Found");
}
if(solo.searchText(TOPDOWNLOAD)==false){
Log.e(TAG, TOPDOWNLOAD + " Not found!!!");
}else{
Log.i(TAG, TOPDOWNLOAD + " Found");
}
//Search for EA in menu
if(solo.searchText(EA)==false){
Log.e(TAG, EA + " Not found!!!");
}else{
Log.i(TAG, EA + " Found");
}
//Search for FEATURED in menu
if(solo.searchText(FEATURED)==false){
Log.e(TAG, FEATURED + " Not found!!!");
}else{
Log.i(TAG, FEATURED + " Found");
}
//Search for GAMES in menu
if(solo.searchText(GAMES)==false){
Log.e(TAG, GAMES + " Not found!!!");
}else{
Log.i(TAG, GAMES + " Found");
}
//Search for APPS in menu
if(solo.searchText(APPS)==false){
Log.e(TAG, APPS + " Not found!!!");
}else{
Log.i(TAG, APPS + " Found");
}
//Search for SOCIAL in menu
if(solo.searchText(SOCIAL)==false){
Log.e(TAG, SOCIAL + " Not found!!!");
}else{
Log.i(TAG, SOCIAL + " Found");
}
//Search for ENTERTAINMENT in menu
if(solo.searchText(ENTERTAINMENT)==false){
Log.e(TAG, ENTERTAINMENT + " Not found!!!");
}else{
Log.i(TAG,ENTERTAINMENT + " Found");
}
//Search for THEMES in menu
if(solo.searchText(THEMES)==false){
Log.e(TAG, THEMES + " Not found!!!");
}else{
Log.i(TAG, THEMES + " Found");
}
//Search for TOOLS in menu
if(solo.searchText(TOOLS)==false){
Log.e(TAG, TOOLS + " Not found!!!");
}else{
Log.i(TAG, TOOLS + " Found");
}
//Search for NEWSin menu
if(solo.searchText(NEWS)==false){
Log.e(TAG, NEWS + " Not found!!!");
}else{
Log.i(TAG, NEWS + " Found");
}
//Search for READING in menu
if(solo.searchText(READING)==false){
Log.e(TAG, READING + " Not found!!!");
}else{
Log.i(TAG, READING + " Found");
}
//Search for MONEY in menu
if(solo.searchText(MONEY)==false){
Log.e(TAG, MONEY + " Not found!!!");
}else{
Log.i(TAG, MONEY + " Found");
}
//Search for SHOPPING in menu
if(solo.searchText(SHOPPING)==false){
Log.e(TAG, SHOPPING + " Not found!!!");
}else{
Log.i(TAG, SHOPPING + " Found");
}
//Search for FITNESS in menu
if(solo.searchText(FITNESS)==false){
Log.e(TAG, FITNESS + " Not found!!!");
}else{
Log.i(TAG, FITNESS + " Found");
}
//Search for TRAVEL in menu
if(solo.searchText(TRAVEL)==false){
Log.e(TAG,TRAVEL + " Not found!!!");
}else{
Log.i(TAG, TRAVEL + " Found");
}
//Search for BUSINESS in menu
if(solo.searchText(BUSINESS)==false){
Log.e(TAG, BUSINESS + " Not found!!!");
}else{
Log.i(TAG, BUSINESS + " Found");
}
//Search for SPANISH in menu
if(solo.searchText(SPANISH)==false){
Log.e(TAG, SPANISH + " Not found!!!");
}else{
Log.i(TAG, SPANISH + " Found");
}
}
searchText中有一個參數可以阻止它滾動。查看javadoc獲取更多信息。 – Renas