UIAutomation - 检查Alert中的消息并将其与预期消息进行比较

use*_*519 1 ui-automation uialertview ios ios-ui-automation

我正在UIAutomation中处理警报.当我遇到警报时,我应该确保警报标题和消息与预期相同.我这样做是为了获取警报标题的访问权限.

var AlertTitle = target.frontMostApp().alert().name();
UIALogger.logMessage(AlertTitle);
Run Code Online (Sandbox Code Playgroud)

以类似的方式,是否有任何方法可以在警报中检索邮件?我试过用

target.frontMostApp().alert().value(); 
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我已经记录了元素树并得到了它.

UIAAlert
 |
 UIAImage
 UIAStaticField name: Abc value: ABc
 UIAStaticField name: XYZ value: XYZ
 UIAButton
Run Code Online (Sandbox Code Playgroud)

我需要在此警报中检索第二个UIAStaticField的值,并与预期值进行比较.我怎么做 ?

我试过这样做,但它没有用.

target.frontMostApp().alert().staticTexts[1]().value();
Run Code Online (Sandbox Code Playgroud)

Gor*_*ght 5

在iOS 7中,它们似乎将staticTexts包装在scrollView中,因此您需要将Jonathan的答案更改为:

target.frontMostApp().alert().scrollViews()[0].staticTexts()[1].value();
Run Code Online (Sandbox Code Playgroud)