Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 =;
            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.

share|improve this question
Are you trying to do this with an IOS app or something else? – Dan Snell Jun 20 '13 at 23:29
@DanSnell iOS App – Lisa Satpathy Jun 21 '13 at 6:08

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.

share|improve this answer
Thanks for the response. I moved my onAlert to the top (before the instance of UITarget)and that made it work. It was not even calling the onAlert function before. – Lisa Satpathy Jun 21 '13 at 20:01
Great - you can add it as an answer below with the code you changed and accepted as an answer. Good luck! – Dan Snell Jun 21 '13 at 20:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.