Search code examples
iosuipopovercontrollerios-ui-automation

UIAutomation: how to access UIPopoverController?


I have an iPad app for which I'm writing an UIAutomation script. There's an UIButton that shows an UIPopoverController when tapped. How can my script select (tap on) an item inside that popover?

Edit: The UIAPopover is not a child of the UIButton it appears on but of mainWindow. So mainWindow.popover() gave it to me. The logElementTree() function is good for debugging and finding elements.


Solution

  • UIALogger.logMessage("tap state");
    var state = buttons[0];
    state.tap();
    
    UIALogger.logMessage("wait for State Popover Screen to display");
    target.delay(1);
    
    UIALogger.logMessage("scroll to District of Columbia");
    window.popover().tableViews()[0].scrollToElementWithName("District of Columbia");
    
    UIALogger.logMessage("select District of Columbia");
    var dc = window.popover().tableViews()[0].cells()["District of Columbia"];
    dc.tap();