private class CrashWatcher implements 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;
}
};
此行有多个标记 - 令牌上的语法错误"。",{预期 - 令牌上的语法错误" getInstance",此令牌后预期的标识符
UiDevice.getInstance().registerWatcher(CRASH_WATCHER_NAME, new UiWatcher());