您的位置:首页 > 其它

老李分享:robotium常用API

2016-02-24 16:38 225 查看

老李分享:robotium常用API

robotium常用API
典型方法:(更多方法及解释请查看以上api)其中很多方法都是根据控件的索引值进行操作① 点击:clickOnButton(int)—Clickson a
Button
with a givenindex.根据索引值点击Button.clickOnButton(String)—Clickson a
Button
with a giventext.根据文本点击Button.clickOnCheckBox(int)—Clickson a
CheckBox
with a givenindex.clickOnView(View)—Clickson a given View.clickOnText(String)—Clickson a
View
displaying agiven text.clickLongOnText(String)—Longclicks on a given
View
.clickOnRadioButton(int)—Clickson a
RadioButton
with a givenindex.clickOnScreen(float, float)—Clickson a given coordinate on the screen.② 取得:getCurrentActivity()—Returnsthe current Activity.getText(String)—Returnsa TextView which shows a given text.getView(int)—Returnsa View with a given id.getEditText(String)—Returnsan EditText which shows a given text. getImage(int)—Returnsan ImageView with a given index.③ 拖拽:drag(float, float, float,float, int)—Simulate touching a given location anddragging it to a new location.④ 搜索:searchText(String)—Searchesfor a text string and returns
true
if at least one item is found with the expected text.searchEditText(String)—Searchesfor a text string in the EditText objects located in the current Activity.searchButton(String, boolean)—Searchesfor a Button with the given text string and returns true if at least one Buttonis found. 断言:具体请查看官网断言方法assert(robotium特有的断言方式,实际项目中和Junit的assert方法配合使用)void assertCurrentActivity (String message, Class activityClass [,booleanisNewInstance])断言当前的activity是否是预期的参数:message-如果运行失败打印的消息activityClass-预期的activityisNewInstance-可选项,实际activity是否是预期activity的继承,如果为true则只要是继承关系就通过,false则必须是当前activity
void assertCurrentActivity (String message, String name [,booleanisNewInstance])断言当前的activity是否是预期的参数:name-预期activity的名字void assertMemoryNotLow()断言目前系统可用内存是否过低,内存空间足够则通过is方法boolean isCheckBoxChecked (intindex | String text)判断checkBox是否处于被选中的状态,可以通过index和text两种方法定位参数:index-检查的checkBox的索引值,如果只有一个可用则为0;text-检查的checkBox的文字,可使用正则表达式.类似的有:boolean isRadioButtonChecked(int index | String text)boolean isToggleButtonChecked(int index | String text)boolean isSpinnerTextSelected ( [intindex, ] String text)boolean isTextChecked (Stringtext)search方法boolean searchButton (Stringtext [, int minimumNumberOfMatches, boolean onlyVisible])判断当前的屏幕中是否能找到指定的button参数:text-查找的button的文字minimumNumberOfMatches-最小指定多少才算是通过,0表示1个或者多个onlyVisible-只记录可见的boolean searchText (String text[, int minimumNumberOfMatches, boolean scroll, boolean onlyVisible])判断当前的屏幕中是否能找到指定的text,即文本参数:text-查找的Text的文字minimumNumberOfMatches-最小指定多少才算是通过,0表示1个或者多个scroll-是否允许滚动搜索,true表示支持,false表示只能在当前屏幕内查找onlyVisible-只记录可见的boolean searchToggleButton(String text [, int minimumNumberOfMatches])boolean searchEditText (Stringtext)判断当前的屏幕中是否能找到指定的EditText
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  测试