Javascript iOS UIAutomation找不到搜索栏

Javascript iOS UIAutomation找不到搜索栏,javascript,ios,ios-ui-automation,Javascript,Ios,Ios Ui Automation,我想在Instruments中使用UIAutomation工具来模拟一些动作。但是我找不到搜索栏。搜索栏位于导航栏下方和表视图上方 我还设定: self.searchBar.isAccessibilityElement = YES; self.searchBar.accessibilityLabel = @"Search Bar"; 但是仍然找不到它。试试这个: var target=UIATarget.localTarget() var app=target.frontMostApp() v

我想在Instruments中使用UIAutomation工具来模拟一些动作。但是我找不到搜索栏。搜索栏位于导航栏下方和表视图上方

我还设定:

self.searchBar.isAccessibilityElement = YES;
self.searchBar.accessibilityLabel = @"Search Bar";
但是仍然找不到它。

试试这个:

var target=UIATarget.localTarget()

var app=target.frontMostApp()

var window=app.mainWindow()

var searchBar=window.searchBar()[0]

searchBar.tap()

如果不起作用,我可以打印应用程序主窗口的elementTree:

logElementTree()


这将记录应用程序窗口中的所有UI元素。您应该查找UIASearchBar。

这里也有同样的问题。我注意到,当您在导航栏上使用logElementTree时,搜索栏没有设置name属性

脚本中的代码:

var navigationBar = UIATarget.localTarget().frontMostApp().navigationBar();
navigationBar.logElementTree();
我得到的结果

UIANavigationBar: name:Gallery rect:{{0, 20}, {320, 44}}
  UIASearchBar: value: rect:{{824, 28}, {84, 28}}
  UIAButton: name:Camera rect:{{212, 27}, {42, 30}}
请注意,按钮的名称为“Camera”,而搜索栏的名称为“Camera”。这就是为什么不能使用搜索栏的名称访问搜索栏。我想是虫子吧