Search code examples
javascriptios6instrumentsiphone-5ios-ui-automation

Automation issue on tabbar in iphone


I am using the automation on instruments tools check my application using the java script when i app have two tabbars when i click the second tab via javascript following code

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();

its worked perfectly. In the product tab have one UITableviewcontroller now i am write the javascript for click the tableview cell like as`

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

is not worked. how can i handle this issue.


Solution

  • I don't think you want to start at the tab bar to find your table view, but I'm not entirely sure I understand your question. I'm working on some UIAutomation scripts as well, so here are a couple of snippets -- hopefully one of them is relevant.

    To tap a button in a UIToolBarController I use this:

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

    You can use the index as well, like [0] for the first tab bar button. On a screen with a UITableView I use this to tap a cell in it:

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

    Again, you can use an index as well. Note that I don't start at the tab bar but instead start with the app variable.

    If something's not working the way you think it should, always log out the tree and take a look at what it contains. That's always helped me:

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

    The Apple documentation on this has more examples.