Monday, July 23, 2012

iPhone UIAutomation Javascript -- Alert View Message

To write UIAutomation Javascript,  one hard part is to handle Alert view,

Here is the example to get Alert view's title and message:

Code:

UIATarget.onAlert = function onAlert(alert){
// To get alert title
var title = alert.name();
//To get alert body message
// [0]  is title
var message = alert.staticTexts()[1].name();

              //if(message == "Are you sure to logout?")
              if(title == "Logout")
                {
                 alert.buttons()["Yes"].tap();
                 return true;
                 }
                 return false;
              }

No comments:

Post a Comment