admin管理员组文章数量:1314086
I'm having a very simple app, which includes a TableViewController, which displays a table with few custom cells with image, label and a button, and when you hit a button, actionSheet shows up. And so, in my custom java script (using Instruments-UIAutomation) I want to push button in my table (and I can do that without any problems), and then when actionSheet appears I just want to tap the only button (Cancel button) that it shows.
And I don't know how to do it properly. So here's my js code:
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var main = app.mainWindow();
main.tableViews()[0].cells()[1].buttons()["DetailsButton"].tap();
target.delay(5);
main.actionSheet().elements()[0].tap();
And that's the message I'm getting:
Script threw an uncaught JavaScript error: 'undefined' is not a function (evaluating 'main.actionSheet()') on line 9 of New%20Script
I've also tried actionSheet().buttons()[0].tap();
- didn't help, keep getting same error.
I even tried to access actionSheet by it's accessibleLabel:
main.actionSheet()["CellNumberSheet"].elements()[0].tap();
If it would help, that's the way I'm showing my actionSheet:
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
The elements hierarchy also seems to be correct.
Didn't find much of a helpful info on it in web... so any help would be appreciated...
I'm having a very simple app, which includes a TableViewController, which displays a table with few custom cells with image, label and a button, and when you hit a button, actionSheet shows up. And so, in my custom java script (using Instruments-UIAutomation) I want to push button in my table (and I can do that without any problems), and then when actionSheet appears I just want to tap the only button (Cancel button) that it shows.
And I don't know how to do it properly. So here's my js code:
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var main = app.mainWindow();
main.tableViews()[0].cells()[1].buttons()["DetailsButton"].tap();
target.delay(5);
main.actionSheet().elements()[0].tap();
And that's the message I'm getting:
Script threw an uncaught JavaScript error: 'undefined' is not a function (evaluating 'main.actionSheet()') on line 9 of New%20Script
I've also tried actionSheet().buttons()[0].tap();
- didn't help, keep getting same error.
I even tried to access actionSheet by it's accessibleLabel:
main.actionSheet()["CellNumberSheet"].elements()[0].tap();
If it would help, that's the way I'm showing my actionSheet:
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
The elements hierarchy also seems to be correct.
Didn't find much of a helpful info on it in web... so any help would be appreciated...
Share Improve this question edited Sep 16, 2014 at 21:19 AstroCB 12.4k20 gold badges59 silver badges74 bronze badges asked Jan 24, 2014 at 11:32 arrtemearrteme 3931 gold badge3 silver badges14 bronze badges4 Answers
Reset to default 6On iOS8, the action sheet buttons and elements just didn't seem to work so I checked in SparkInspector and it uses a collection view now:
This code will tap the bottom button that isn't the cancel button:
target.frontMostApp().actionSheet().collectionViews()[0].visibleCells()[0].tap()
When you want to tap on actionSheet you must use as below:
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var window = app.mainWindow();
target.frontMostApp().actionSheet().buttons()["Cancel"].tap();
But if you use window.actionSheet()
it will return error.
Actually you need to use app.actionSheet() to get the actionsheet.
See UIAApplication
app.actionSheet().elements()[0].tap();
This should work
Try using this :
//check that action sheet is on the screen
app.actionSheetIsValid();
//add some delay
target.delay(2);
//check that the button is on the actionSheet
actionSheet.actionSheetButton("Cancel");
//add some delay
target.delay(2);
//touch Exit button
actionSheet.tapActionSheetButtonByName("Cancel");
本文标签: iosHow to access actionSheet (and it39s buttons) in UIAutomation with JavaScriptStack Overflow
版权声明:本文标题:ios - How to access actionSheet (and it's buttons) in UIAutomation with JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741960251a2407235.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论