Changes between Version 16 and Version 17 of androidtest


Ignore:
Timestamp:
10/29/2014 10:05:46 AM (11 years ago)
Author:
liaojiaohe
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • androidtest

    v16 v17  
    146146}}} 
    147147 
     148 
     149 
     150== 是用uiautomator 测试 == 
     151 
     152http://developer.android.com/tools/testing/testing_ui.html [[BR]] 
     153 
     154先用自带工具 uiautomatorviewer 看页面元素,再写程序 [[BR]] 
     155 
     156代码如 
     157 
     158{{{ 
     159 
     160      getUiDevice().pressHome(); 
     161       
     162      UiObject allAppsButton = new UiObject(new UiSelector() 
     163         .description("Apps")); 
     164       
     165      allAppsButton.clickAndWaitForNewWindow(); 
     166       
     167      UiObject appsTab = new UiObject(new UiSelector() 
     168         .text("Apps")); 
     169       
     170      appsTab.click(); 
     171 
     172      UiScrollable appViews = new UiScrollable(new UiSelector() 
     173         .scrollable(true)); 
     174       
     175      appViews.setAsHorizontalList(); 
     176       
     177      UiObject settingsApp = appViews.getChildByText(new UiSelector() 
     178         .className(android.widget.TextView.class.getName()),  
     179         "Settings"); 
     180      settingsApp.clickAndWaitForNewWindow(); 
     181       
     182      UiObject settingsValidation = new UiObject(new UiSelector() 
     183         .packageName("com.android.settings")); 
     184      assertTrue("Unable to detect Settings",  
     185         settingsValidation.exists());    
     186}}} 
     187