Create test cases on the fly
Helper
function runTestcase(description, teststeps) {
try {
UIALogger.logStart(description);
teststeps();
UIALogger.logPass("Testcase passed");
} catch (exception) {
UIALogger.logError(exception.message);
target.logElementTree();
UIALogger.logFail("Testcase failed");
throw exception;
}
}
Example
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var window = app.mainWindow();
runTestcase("Press register button", function() {
var expected = "register button";
var register_btn = window.buttons()["Register"];
if (!register_btn.isValid()) {
throw new Error("not found: '" + expected + "'");
} else {
register_btn.tap();
}
});