Robotium 常用方法

Robotium 常用方法①点击:clickOnButton(int)//ClicksonaButtonwithagivenindex.clickOnButton(String)//ClicksonaButtonwithagiventext.clickOnCheckBox(int)//ClicksonaCheckBoxwithagivenindex.clickOnVie

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

① 点击:

clickOnButton(int) //Clicks on a Button with a given index.
clickOnButton(String) //Clicks on a Button with a given text.
clickOnCheckBox(int) //Clicks on a CheckBox with a given index.
clickOnView(View) //Clicks on a given View.
clickOnText(String) //Clicks on a View displaying a given text.
clickLongOnText(String) //Long clicks on a given View.
clickOnRadioButton(int) //Clicks on a RadioButton with a given index.
clickOnScreen(float, float) //Clicks on a given coordinate on the screen.

② 取得:

getCurrentActivity() //Returns the current Activity.
getText(String) //Returns a TextView which shows a given text.
getView(int) //Returns a View with a given id.
getEditText(String) //Returns an EditText which shows a given text. 
getImage(int) //Returns an ImageView with a given index.

③ 拖拽:

drag(float, float, float, float, int) //Simulate touching a given location and dragging it to a new location.

④ 搜索:

searchText(String) //Searches for a text string and returns true if at least one item is found with the expected text.
searchEditText(String) //Searches for a text string in the EditText objects located in the current Activity.
searchButton(String, boolean) //Searches for a Button with the given text string and returns true if at least one Button is found.

功能是点击Menu按钮,选择文本描述为String的菜单,如我们的例子是”Add note”

clickOnMenuItem(String);

这个是判断当前的activity是否和我预期的一致 message是描述性的文字 name是指activity的名字 关于如何知道activity 名字,目前的方法是得看源码中的 AndroidManifest.xml–Application label–Application Nodes,在那里我们可以看到所有的activity的name

assertCurrentActivity(String message,String name);

index用来标识写到哪个EditText中。如果当前只打开一个EditText,那index=0 text:就是我们要写入的内容

enterText(int index,string text);

相当于手机上的 返回键(back key)

goBack();

返回到指定的activity

goBackToActivity(String name);

在当前的activity中搜索是否含有text的内容

searchText(String text)

点击list表的第index行,进入该文本界面

clickInList(int index);

setActivityOrientation,设置手机屏幕显示方式 LANDSCAPE:横向显示 Portrait:竖向显示

solo.setActivityOrientation(Solo.LANDSCAPE);

点击包含该文字的地方 其中text可以用正则表达式表示 (?i)—-忽略大小写。默认情况是大小写敏感的。 正则表达式与java保持一致

clickOnText(String text);

长时间按住所选的文字

clickLongOnText(String text);
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/160084.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号