UIautomator 自动化测试脚本的问题

hxdlovewb 2017-08-01 01:26:46
package com.example.helloworld.test;

import java.io.File;
import java.security.PublicKey;

import android.os.RemoteException;

import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;

public class TestForMcLTEContact1 extends UiAutomatorTestCase{
public void testformcltecontact1() throws RemoteException {
try {
while (UiDevice.getInstance().isScreenOn()) {
//System.out.println("灭屏状态");
// }else{
if (new UiObject(new UiSelector().description("应用")).exists()) {
UiDevice.getInstance().takeScreenshot(new File("/mnt/sdcard/1.png"));
new UiObject(new UiSelector().description("应用")).click();
if (new UiObject(new UiSelector().text("集群")).exists()) {
UiDevice.getInstance().takeScreenshot(new File("/mnt/sdcard/2.png"));
new UiObject(new UiSelector().text("集群")).click();
if (new UiObject(new UiSelector().resourceId("com.bjkyhx.McLTE:id/main_contacts")).exists()) {
UiDevice.getInstance().takeScreenshot(new File("/mnt/sdcard/4.png"));
UiDevice.getInstance().pressHome();
UiDevice.getInstance().sleep();
}
}
else {
UiDevice.getInstance().swipe(300, 300, 400, 500, 50);
UiDevice.getInstance().takeScreenshot(new File("/mnt/sdcard/3.png"));
new UiObject(new UiSelector().text("集群")).click();
if (new UiObject(new UiSelector().resourceId("com.bjkyhx.McLTE:id/main_bottom")).exists()) {
UiDevice.getInstance().takeScreenshot(new File("/mnt/sdcard/5.png"));
}
}

}
}
} catch (Exception e) {
// TODO: handle exception
//System.out.println(e.toString());
}
}
}
上面是代码,可运行,但是就是运行不正常,求解答。
...全文
160 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

58,442

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧