最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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();
发布评论

评论列表(0)

  1. 暂无评论