package com.yang.clicktest;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
public class UiClickTest extends UiAutomatorTestCase {
public void testClick() throws UiObjectNotFoundException{ // case名需要以 test 打头
pressBack(); // 执行case前先返回退出之前的页面
UiDevice.getInstance().pressHome(); // 回到home页面
UiObject alarm = new UiObject(new UiSelector().resourceId("com.sec.android.app.clockpackage:id/alarm_item"));
alarm.clickBottomRight();
UiObject cancel = new UiObject(new UiSelector().resourceId("com.sec.android.app.clockpackage:id/Menu_Cancel"));
cancel.click();
}
public void test2() throws UiObjectNotFoundException{
pressBack();
UiDevice.getInstance().pressHome();
UiObject Contacts = new UiObject(new UiSelector().text("Contacts"));
Contacts.dragTo(150, 250, 5);
}
public void test3() throws UiObjectNotFoundException{
pressBack();
UiDevice.getInstance().pressHome();
UiObject Contacts = new UiObject(new UiSelector().text("Contacts"));
Contacts.dragTo(150, 250, 5);
}
public void test_not_found_test(){
assertTrue(true);
}
void pressBack(){
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
}
}
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
public class UiClickTest extends UiAutomatorTestCase {
public void testClick() throws UiObjectNotFoundException{ // case名需要以 test 打头
pressBack(); // 执行case前先返回退出之前的页面
UiDevice.getInstance().pressHome(); // 回到home页面
UiObject alarm = new UiObject(new UiSelector().resourceId("com.sec.android.app.clockpackage:id/alarm_item"));
alarm.clickBottomRight();
UiObject cancel = new UiObject(new UiSelector().resourceId("com.sec.android.app.clockpackage:id/Menu_Cancel"));
cancel.click();
}
public void test2() throws UiObjectNotFoundException{
pressBack();
UiDevice.getInstance().pressHome();
UiObject Contacts = new UiObject(new UiSelector().text("Contacts"));
Contacts.dragTo(150, 250, 5);
}
public void test3() throws UiObjectNotFoundException{
pressBack();
UiDevice.getInstance().pressHome();
UiObject Contacts = new UiObject(new UiSelector().text("Contacts"));
Contacts.dragTo(150, 250, 5);
}
public void test_not_found_test(){
assertTrue(true);
}
void pressBack(){
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
UiDevice.getInstance().pressBack();
}
}