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 badge3 Answers
Reset to default 6If 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();