Android 自动化测试—robotium(五)Spinner控件

spinne控件:



 

默认显示:【选择的是:北京】

操作步骤:

1.点击【城市】下拉框

2.选择【上海】

验证:TextView 显示:【选择的是:上海】

  1. public void testUI() throws Exception { 
  2.        this.Spinner(); 
  3.  
  4. public void Spinner(){ 
  5.     solo.clickOnButton("Spinner"); 
  6.     boolean actual = solo.isSpinnerTextSelected(0,"北京"); 
  7.  
  8.     solo.pressSpinnerItem(01); 
  9.     boolean actual1 = solo.searchText("选择的是:上海"); 
  10.     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

猜你喜欢

转载自284772894.iteye.com/blog/2167199