javascript - UI Automation:iPhone app - how to tap "OK" button when an alert appears - Stack Overflow

1) UIATarget [name:(null)value:(null) NSRect: {{2.7520829e-39,2.0667855e-36},{0, 1.4012985e-45}}]2) UIA

1) UIATarget [name:(null)value:(null) NSRect: {{2.7520829e-39,2.0667855e-36},{0, 1.4012985e-45}}]

2) UIAApplication [name:tosh.0 value:(null) NSRect:{{0, 20}, {320, 460}}]

3) UIAWindow [name:(null) value:(null) NSRect: {{0, 0}, {320, 480}}]

4)....

5)....

3) UIAWindow [name:(null) value:(null) NSRect:{{0, 0}, {320, 480}}]

4) UIAAlert [name:(null) value:(null) NSRect:{{18, 180}, {284, 141}}]

5) UIAStaticText [name:Unable to connect value:(null) NSRect: {{30, 225}, {260, 21}}]

5) UIAButton [name:OK value:(null) NSRect: {{29, 262}, {262, 43}}]

How can I press "OK" on the second UIAWindow, please. give syntax.

1) UIATarget [name:(null)value:(null) NSRect: {{2.7520829e-39,2.0667855e-36},{0, 1.4012985e-45}}]

2) UIAApplication [name:tosh.0 value:(null) NSRect:{{0, 20}, {320, 460}}]

3) UIAWindow [name:(null) value:(null) NSRect: {{0, 0}, {320, 480}}]

4)....

5)....

3) UIAWindow [name:(null) value:(null) NSRect:{{0, 0}, {320, 480}}]

4) UIAAlert [name:(null) value:(null) NSRect:{{18, 180}, {284, 141}}]

5) UIAStaticText [name:Unable to connect value:(null) NSRect: {{30, 225}, {260, 21}}]

5) UIAButton [name:OK value:(null) NSRect: {{29, 262}, {262, 43}}]

How can I press "OK" on the second UIAWindow, please. give syntax.

Share Improve this question edited Sep 22, 2011 at 19:33 nschum 15.4k5 gold badges60 silver badges56 bronze badges asked Mar 14, 2011 at 10:17 DmitriDmitri 11 silver badge1 bronze badge
Add a ment  | 

3 Answers 3

Reset to default 6

If an allert appears, a callback in your automation script gets active. If you just want to dismiss it with the default behavour you should implement it like that:

UIATarget.onAlert = function onAlert(alert) 
{   
    return false; 
}

The allert will be dismissed by returning false. If you want to click OK explizitely implement it like that:

alert.buttons()["OK"].tap();
return true; // to bypass the default handler 

If you want to show an info, just use an UIAlertView/UIView without any buttons and hide it after a few seconds.

Hey.
But are you using Instruments and UIAutomation? it is not clear from your question for what technology you need code/syntax.

For Instruments+UIAutomation+JavaScript, it can be like this:

   UIATarget.localTarget().frontMostApp().alert().elements()[1].tap();

or

   UIATarget.localTarget().frontMostApp().alert().defaultButton().tap();

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744698384a4588632.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信