【发布时间】:2014-06-27 17:42:26
【问题描述】:
我正在使用 UiWatcher 编写崩溃代码,但我的团队负责人评论说他需要一个“不是匿名类。一个适当的私有类。”那么我如何使用 UiWatcher() 来做到这一点
private void CrashWatcher() {
UiWatcher crash = new UiWatcher() {
//我的领导评论:不是匿名类。一个适当的私人课程。
public boolean checkForCondition() {
UiObject crashButton = new UiObject(
new UiSelector().textStartsWith("Unfortunately,"));
if (crashButton.exists()) {
log("Found the OK dialog");
UiObject okButton = new UiObject(new UiSelector()
.className("android.widget.Button").text("OK"));
try {
okButton.click();
} catch (UiObjectNotFoundException e) {
log("The chance of not having 'OK' button when the application crash is extremely less.");
return false;
}
}
return true;
}
};
// Register watcher
UiDevice.getInstance().registerWatcher(CRASH_WATCHER_NAME, crash);
}
【问题讨论】:
标签: java android automation android-uiautomator