Если кому-то еще это понадобится, вот мой сценарий для этого.Правильная функция входа будет аналогичной.
function wrongSignIn() {
// Assume you are on the signin page already
var target = UIATarget.localTarget();
var appWindow = target.frontMostApp().mainWindow();
// Assume you name the text fields username/password and they are accessible
appWindow.textFields()["username"].setValue("correct username");
appWindow.textFields()["password"].setValue("wrong password");
// Assume you have a button called "Sign in"
appWindow.buttons()["Sign in"].tap();
// Probably you need some delay for the UI to appear
target.delay(3);
var alert = target.frontMostApp().alert();
// Make sure the alert is on screen with right message, and stay on old screen
if (alert.checkIsValid() && alert.name() == "Wrong password!"
&& appWindow.name() == "Sign in") {
UIALogger.logPass("Pass the wrong signin test.");
} else {
UIALogger.logFail("Fail the wrong signin test.");
}
}