緊接之前的創(chuàng)建一個Note的Appium和Robotium的實例,這里給出實現同樣功能的UIAutomator的實例如下:

專業(yè)從事成都網站建設、成都網站制作,高端網站制作設計,小程序開發(fā),網站推廣的成都做網站的公司。優(yōu)秀技術團隊竭力真誠服務,采用HTML5建站+CSS3前端渲染技術,成都響應式網站建設公司,讓網站在手機、平板、PC、微信下都能呈現。建站過程建立專項小組,與您實時在線互動,隨時提供解決方案,暢聊想法和感受。
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(); } }
網站名稱:UIAutomator創(chuàng)建一個Note的實例
標題鏈接:http://chinadenli.net/article44/jggehe.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供服務器托管、網站維護、網頁設計公司、品牌網站制作、網站制作、網站收錄
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)