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