Reputation: 515
I am writing automation test scripts using Automation tool in instruments for my iPad app. In the login screen, when user taps on login button without entering any information, I display an error message. This error message is displayed on a label which is initially invisible and when the error message has to be displayed, it is made visible and the error is shown in that label. I want to check if the error message displayed in that label is the same as the one I am expecting to receive. How do I do that ?
Upvotes: 0
Views: 422
Reputation: 223
First write the script so that error message appears on screen and then write
target.logElementTree();
So you will be able to see its element hierarchy and then just compare it with your expected error message like
if (mainWindow.staticTexts()[0].name() == "expected_alert_message") {log_Pass} else {log_Fail}
Upvotes: 1