网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

UIAutomator创建一个Note的实例

紧接之前的创建一个Note的Appium和Robotium的实例,这里给出实现同样功能的UIAutomator的实例如下:

专业从事成都网站建设、成都网站制作,高端网站制作设计,小程序开发,网站推广的成都做网站的公司。优秀技术团队竭力真诚服务,采用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创建一个Note的实例
地址分享:http://bjjierui.cn/article/jggehe.html

其他资讯