How to select a cell in a tableView thats inside an alertView in UIAutomation?



  • I am a beginner to UIAutomation. I wanted to know how do I tap one of the cells in a tableView thats inside an alert. As per Apple's UI automation documentation an alert will by default tap the cancel button if you dont specifically handle the alert and return true.

    I tried the below written code (found at Apple developer). But this is still tapping the cancel button.

    // second alert box "Nearby listings:"
    UIATarget.onAlert = function onAlert(alert) {
        var title = alert.name();
        UIALogger.logWarning("Alert with title ’" + title + "’     encountered!");
        if (title == "Nearby listings:") {
            target.frontMostApp().alert().tableViews()["Empty list"].cells()[2].tap(); //    tapping the second cell
            return true; // bypass default handler
        }
    }
    

    I would highly appreciate any kind of help.



  • You may want to take a look at the index position of the cell you are trying to tap.

    I am guessing that:

    target.frontMostApp().alert().tableViews()["Empty list"].cells()[2].tap();
    

    The [2] is likely the index position of that element in your collection. Take a look at the position of the cell in your collection and set the index accordingly.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2