UIAutomator创建一个Note的实例
来源:互联网 发布:淘宝宝贝关联怎么弄 编辑:程序博客网 时间:2024/06/09 18:41
紧接之前的创建一个Note的Appium和Robotium的实例,这里给出实现同样功能的UIAutomator的实例如下:
- package majcit.com.UIAutomatorDemo;
- import com.android.uiautomator.core.UiDevice;
- import com.android.uiautomator.core.UiObject;
- import com.android.uiautomator.core.UiObjectNotFoundException;
- import com.android.uiautomator.core.UiScrollable;
- import com.android.uiautomator.core.UiSelector;
- import com.android.uiautomator.testrunner.UiAutomatorTestCase;
- public class NotePadTest extends UiAutomatorTestCase {
- public void testDemo() throws UiObjectNotFoundException {
- UiDevice device = getUiDevice();
- device.pressHome();
- // Start Notepad
- UiObject appNotes = new UiObject(new UiSelector().text("Notes"));
- appNotes.click();
- //Sleep 3 seconds till the app get ready
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- //Evoke the system menu option
- device.pressMenu();
- UiObject addNote = new UiObject(new UiSelector().text("Add note"));
- addNote.click();
- //Add a new note
- UiObject noteContent = new UiObject(new UiSelector().className("android.widget.EditText"));
- noteContent.clearTextField();
- noteContent.setText("Note 1");
- device.pressMenu();
- UiObject save = new UiObject(new UiSelector().text("Save"));
- save.click();
- //Find out the new added note entry
- UiScrollable noteList = new UiScrollable( new UiSelector().className("android.widget.ListView"));
- //UiScrollable noteList = new UiScrollable( new UiSelector().scrollable(true));
- UiObject note = null;
- if(noteList.exists()) {
- note = noteList.getChildByText(new UiSelector().className("android.widget.TextView"), "Note1", true);
- //note = noteList.getChildByText(new UiSelector().text("Note1"), "Note1", true);
- }
- else {
- note = new UiObject(new UiSelector().text("Note1"));
- }
- //assertThat(note,notNullValue());
- note.longClick();
- UiObject delete = new UiObject(new UiSelector().text("Delete"));
- delete.click();
- }
- }
0 0
- UIAutomator创建一个Note的实例
- UIAutomator创建一个Note的实例
- UIAutomator创建一个Note的实例
- Appium创建一个Note的实例
- Robotium创建一个Note的实例
- SDK Instrumentation创建一个Note的实例
- MonkeyRunner创建一个Note的实例
- fullcalendar创建的一个实例
- android uiautomator写一个崩溃的监听
- NOTE 4----linkserver的创建
- 创建只有一个实例的类
- 创建只有一个实例的类
- 创建XMLHttpRequest对象的一个实例
- 一个创建多个线程的实例
- 创建XMLHttpRequest对象的一个实例
- 创建XMLHttpRequest对象的一个实例
- 创建XMLHttpRequest对象的一个实例
- 表示创建一个数组的实例
- 使用poi读xls文件遇到的不可思议的问题,
- 设计模式总览
- JVM虚拟机结构
- 11张图,教你看懂“互联网小子”与“传统老大爷”的本质区别
- CMake入门教程
- UIAutomator创建一个Note的实例
- 使用LUA 热更新模块
- DNS
- Intel 集成显卡的Linux驱动安装
- 对生命周期回调函数的认识————starting an activity
- 各大IT网站!
- linux wa%过高,iostat查看io状况
- 矩阵连乘的动态规划算法(包括递归的备忘录方法)
- 最强开发资源平台大合集