public class BTest extends UiAutomatorTestCase { public void testPersonCenter() throws UiObjectNotFoundException { UiDevice device = getUiDevice(); // 启动 launchapp(); //点击首页头像 根据id选择控件 clickPersonCenter(); //挨个执行 personPage(); } // 启动桌面app private void launchapp() throws UiObjectNotFoundException { UiObject start = new UiObject(new UiSelector().text("百度地图"));// start.click(); sleep(1000); } private void clickPersonCenter() throws UiObjectNotFoundException { UiObject start = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); start.click(); sleep(1000); } private void personPage() throws UiObjectNotFoundException { // 点击账号 UiObject start = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); start.click(); sleep(1000); //退出取消 UiObject cancel = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); cancel.click(); sleep(1000); // 点击 搜周边 UiObject around = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); around.click(); sleep(1000); // 退出周边 UiObject aroundCancel = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); aroundCancel.click(); sleep(1000); //收藏夹com.baidu.naviauto:id/collectionContainer UiObject collection = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); collection.click(); sleep(1000); // 退出收藏夹com.baidu.naviauto:id/ib_left UiObject collectionCancel = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); collectionCancel.click(); sleep(1000); // 地图数据com.baidu.naviauto:id/mapDataContainer UiObject mapDataContainer = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); mapDataContainer.click(); sleep(1000); //退出地图数据 com.baidu.naviauto:id/ib_left UiObject mapDataContainerCancel = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); mapDataContainerCancel.click(); sleep(1000); //设置com.baidu.naviauto:id/settingContainer UiObject settingContainer = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); settingContainer.click(); sleep(1000); //退出设置com.baidu.naviauto:id/btnBack UiObject settingContainerCancel = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); settingContainerCancel.click(); sleep(1000); //帮助com.baidu.naviauto:id/helpFeedbackContainer UiObject helpFeedbackContainer = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); helpFeedbackContainer.click(); sleep(1000); // 退出帮助com.baidu.naviauto:id/ib_left UiObject helpFeedbackContainerCancel = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); helpFeedbackContainerCancel.click(); sleep(1000); //退出com.baidu.naviauto:id/exitContainer UiObject exitContainer = new UiObject(new UiSelector().resourceId("com.xxx:id/id")); exitContainer.click(); sleep(2000); //启动 launchapp(); } }
android 自动化测试 二 根据id选择控件操作
最新推荐文章于 2023-08-17 11:19:14 发布