????????????????в???????ListView?е????????????Apps????????
UiObjectappItem=newUiObject(newUiSelector()
.className("android.widget.ListView").instance(1)
.childSelector(newUiSelector().text("Apps")));
??????β?????????????е????????????????
????UiObjectcancelButton=newUiObject(newUiSelector().text("Cancel"));
????UiObjectokButton=newUiObject(newUiSelector().text("OK"));
???????????UiObject?????????????????????????á?????????????????UiObject???????????uiautomator??????????????2????????
???????′???uiautomator???????????????????????“OK”????????????????????????????????????
if(okButton.exists()&&okButton.isEnabled())
{
okButton.click();
}
????????????????????????????????????????′????????????“Cancel”??“OK”??android.widget.Button????????
UiObjectcancelButton=newUiObject(newUiSelector().text("Cancel")
.className("android.widget.Button"));
UiObjectokButton=newUiObject(newUiSelector().text("OK")
.className("android.widget.Button"));
UiCollection
???????????????????UiCollection??????UiObject????????UiSelector?????UiCollection???Android???е?ViewGroup?????????
???????′????????????UiSelector?????????????????UiCollection??
????UiCollectionvideos=newUiCollection(newUiSelector()
????.className("android.widget.FrameLayout"));
?????????????????LinearLayout?е?????????????·???????????????
????intcount=videos.getChildCount(newUiSelector()
????.className("android.widget.LinearLayout"));
?????????????????“CuteBabyLaughing”?????????????????????????·????
UiObjectvideo=videos.getChildByText(newUiSelector()
.className("android.widget.LinearLayout")??"CuteBabyLaughing");
video.click();
????????????????????????????????磬?????????????????£?
UiObjectcheckBox=video.getChild(newUiSelector()
.className("android.widget.Checkbox"));
if(!checkBox.isSelected())checkbox.click();
UiScrollable
????????????????????????UiScrollable???????????????????UI????????????????????????????????????????????????????????UiScrollable??
???????磬????????????????????????“Settings”????????“Abouttablet”??????????
UiScrollablesettingsItem=newUiScrollable(newUiSelector()
.className("android.widget.ListView"));
UiObjectabout=settingsItem.getChildByText(newUiSelector()
.className("android.widget.LinearLayout")??"Abouttablet");
about.click()