0

We only support landscape mode and for some reason when we would push to a different view controller, rotate the app, then pop, our UISearchBar would then take up the entire navigationBar and pushing even the title to the LHS. So we ended up wrapping the UISearchBar in a UIToolbar and that seemed to fix the issue.

So on the second view controller that gets pushed onto the stack, we have a UISearchbar in a UIToolbar in a UINavigationBar. I can't seem to access it. I wanted to write a script to enter some search items and click on those items so when our data model changes, we don't get crashes.

The problem I am having is I'm not sure how to access it. I am assuming that

UIATarget.localTarget().frontMostApp().mainWindow()

can be used on screens that aren't just the rootViewController. So I try to do

UIATarget.localTarget().frontMostApp().mainWindow().navigationBar().toolBar().tap();

But that dow not work. I am assuming navigationBar().buttons()[---] would not provide any use either since it's not a button I'm trying to access. When I do

window.logElementTree();

I see:

UIAWindow
-> UIANavigationBar
-> -> UIAButton
-> -> UIAToolbar  // (I'm trying to show the disclosure triangles in how it looks like in the log.

So I can see the navigationBar I need, and the toolBar underneath it, but not sure how to get to it.

I also tried this

var navBarElements = window.navigationBar().elements();

for (var elem in navBarElements) {
    if (elem["Toolbar"]) {
        UIALogger.logMessage("toolbar");            
    }
}

In my code's viewDidLoad when I create the toolbar, I have this:

UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 160, 44)];
toolbar.accessibilityIdentifier = @"Toolbar";

But I never get the logMessage indicating that I have the right item. Am I stuck trying to just use the screen and tapping on it? Thanks!

nschum
  • 15,322
  • 5
  • 58
  • 56
Crystal
  • 28,460
  • 62
  • 219
  • 393
  • 1
    Have you tried to record your automation events in the Instruments editor and to find out the access-code that way? – brainray Apr 14 '12 at 21:37

1 Answers1

0

try to use the the function that returns UIAElementArray of objects but not an UIAElement

UIATarget.localTarget().frontMostApp().mainWindow().navigationBar().toolBars()[<LabelOfToolBarOrIndexStartingFromZero>].tap();

or even

UIATarget.localTarget().frontMostApp().mainWindow().navigationBars()[<NameOfNavigationBarOrIndexStartingFromZero>].toolBars()[<LabelOfToolBarOrIndexStartingFromZero>]].tap();

By the way, try to replace the

if (elem["Toolbar"])

with

if (elem["object UIAToolbar"])
Sh_Andrew
  • 352
  • 2
  • 6