Spinner 控件:
默認顯示:【選擇的是:北京】
操作步驟:
1.點擊【城市】下拉框
2.選擇【上海】
驗證:TextView 顯示:【選擇的是:上海】
- public void testUI() throws Exception {
- this.Spinner();
- }
-
- public void Spinner(){
- solo.clickOnButton("Spinner");
- boolean actual = solo.isSpinnerTextSelected(0,"北京");
-
- solo.pressSpinnerItem(0, 1);
- boolean actual1 = solo.searchText("選擇的是:上海");
- assertEquals("This is not found",true, actual1);
- }
isSpinnerTextSelected 擁有兩個參數
public boolean isSpinnerTextSelected(int index, String text)
index:定位選擇的Spinner,第一個爲0
text:所選擇的Spinner存在的文本
這個API返回的是一個布爾值,當滿足條件時返回true
pressSpinnerItem 擁有兩個參數
public void pressSpinnerItem(int spinnerIndex, int itemIndex)
spinnerIndex:定位要使用的Spinner,第一個爲0
intemIndex:定位所要按下的下拉項,如圖:北京=0 上海=1 天津=2 ....
Spinner實現:http://luwenjie.blog.51cto.com/925779/917238
本文出自 “小毛子” 博客,請務必保留此出處http://xiaomaozi.blog.51cto.com/925779/917287