hxdlovewb 2017-08-01 05:23 采纳率: 0%
浏览 2073

UIautomator 测试脚本 可运行,运行不正常,不停止。代码如下

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());
    }
}

}
调了一上午了,求解答!
图片说明

  • 写回答

2条回答 默认 最新

  • dabocaiqq 2018-06-26 16:07
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退