robotium常用API
2015-06-03 16:18
369 查看
robotium常用API
Robotium中最重要的类Solo类:其中提供了模拟用户活动的点击、搜索、拖拽等方法。
英文api(经常断开连接打不开):http://www.jarvana.com/jarvana/view/com/jayway/android/robotium/robotium-solo/2.0.1/robotium-solo-2.0.1-javadoc.jar!/index-all.html
中文API: http://www.robotium.cn/archives/category/api/page/7
(源代码解析-Solo : http://www.robotium.cn/archives/1050)
典型方法:(更多方法及解释请查看以上api)
其中很多方法都是根据控件的索引值进行操作
① 点击:
clickOnButton(int)—Clickson a
clickOnButton(String)—Clickson a
clickOnCheckBox(int)—Clickson a
clickOnView(View)—Clickson a given View.
clickOnText(String)—Clickson a
clickLongOnText(String)—Longclicks on a given
clickOnRadioButton(int)—Clickson a
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
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
Robotium中最重要的类Solo类:其中提供了模拟用户活动的点击、搜索、拖拽等方法。
英文api(经常断开连接打不开):http://www.jarvana.com/jarvana/view/com/jayway/android/robotium/robotium-solo/2.0.1/robotium-solo-2.0.1-javadoc.jar!/index-all.html
中文API: http://www.robotium.cn/archives/category/api/page/7
(源代码解析-Solo : http://www.robotium.cn/archives/1050)
典型方法:(更多方法及解释请查看以上api)
其中很多方法都是根据控件的索引值进行操作
① 点击:
clickOnButton(int)—Clickson a
Buttonwith a givenindex.根据索引值点击Button.
clickOnButton(String)—Clickson a
Buttonwith a giventext.根据文本点击Button.
clickOnCheckBox(int)—Clickson a
CheckBoxwith a givenindex.
clickOnView(View)—Clickson a given View.
clickOnText(String)—Clickson a
Viewdisplaying agiven text.
clickLongOnText(String)—Longclicks on a given
View.
clickOnRadioButton(int)—Clickson a
RadioButtonwith 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
trueif 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
相关文章推荐
- 设计模式之原型模式
- kafka HighLevelConsumer API 使用案例
- 拉筋的正确方法
- C语言 全排列
- Oracle - 数据库的实例、表空间、用户、表之间关系
- 水印php
- TreeSet中的问题
- CSDN博客之星——找到自己的榜样
- 根据两点的经纬度求方位角和距离,等
- cookie中存放购物车(一)
- HDU5246 超级赛亚ACMer
- CAD2GIS:arcengine注记添加
- T410 I7 1440x900 GMA5700核显(集显)安装OSX hackintosh 10.9.1成功
- 安装BIRT Chart Engine的时候,提示Cannot complete the install because one or more required items could not be
- 商业分析能力是怎样炼成的?
- 互联网-端口号
- 【绿皮】新GRE填空补充练习题Exercise6
- 使用DLL进行不同语言之间的调用(转)
- hdu 1203 I NEED A OFFER!(01背包)
- 《Java编程思想》学习笔记10——文件和目录常用操作