【问题标题】:Automation issue on tabbar in iphoneiphone标签栏上的自动化问题
【发布时间】:2012-12-05 06:09:08
【问题描述】:

当我通过以下代码通过javascript单击第二个选项卡时,当我的应用程序有两个标签栏时,我正在使用仪器工具上的自动化检查我的应用程序

var target = UIATarget.localTarget();

var app = target.frontMostApp();
var window = app.mainWindow();
var tabbar = window.tabBar().buttons()["Product"].tap();
UIALogger.logStart("Logging element tree …");
UIALogger.logPass();

它工作得很好。在产品选项卡中有一个 UITableviewcontroller 现在我正在编写用于单击 tableview 单元格的 javascript,如`

tabar.tableviews()[0].cells()[0].tab;

不工作。我该如何处理这个问题。

【问题讨论】:

    标签: javascript ios6 instruments iphone-5 ios-ui-automation


    【解决方案1】:

    我认为您不想从标签栏开始查找表格视图,但我不完全确定我理解您的问题。我也在处理一些 UIAutomation 脚本,所以这里有几个 sn-ps——希望其中一个是相关的。

    要点击 UIToolBarController 中的按钮,我使用这个:

    var app = target.frontMostApp();
    app.mainWindow().tabBar().buttons()["Saved"].tap(); // The name of the button is "Saved".
    

    您也可以使用索引,例如第一个标签栏按钮的 [0]。在带有 UITableView 的屏幕上,我使用它来点击其中的一个单元格:

    app.mainWindow().tableViews()[0].cells()["Name"].tap(); // The cell is named "Name".
    

    同样,您也可以使用索引。请注意,我不是从标签栏开始,而是从 app 变量开始。

    如果某些事情没有按照您认为的方式运行,请始终注销树并查看其中包含的内容。这一直对我有帮助:

    app.mainWindow().tableViews()[0].logElementTree();
    

    这里的Apple documentation 有更多示例。

    【讨论】:

    • 感谢您的回复。我已经得到了答案。我给您答案的任何方式都是正确的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 2018-04-13
    相关资源
    最近更新 更多