I am working on alerts in UIAutomation. When I encounter an alert, I am supposed to ensure that the alert title and message are the same as expected. I have done this to get access for alert title.
var AlertTitle = target.frontMostApp().alert().name();
UIALogger.logMessage(AlertTitle);
In the similar way, is there any way to retrieve the message in alert ? I have tried using
target.frontMostApp().alert().value();
but it did not work. I have logged the element tree and got this.
UIAAlert
|
UIAImage
UIAStaticField name: Abc value: ABc
UIAStaticField name: XYZ value: XYZ
UIAButton
I need to retrieve the value of second UIAStaticField in this alert and compare with expected value. How do I do that ?
I tried doing this but it didn't work.
target.frontMostApp().alert().staticTexts[1]().value();
You're so close! You've got the parentheses and brackets backward in your line. Do it this way:
target.frontMostApp().alert().staticTexts()[1].value();
That way, you are calling the staticTexts()
method on the alert to get the element array and then using the bracket syntax to get the second element.