3

I've got an activity indicator on my root table view while things get loaded. I'm trying to test for the presence of the indicator, but can't seem to get ahold of the UIAActivityIndicator, nor can I find it anywhere in the app element tree hierarchy. The indicator is a subview of the root table view, so I'd expect it to be seen as a part of that element tree, but I don't see it anywhere (other than physically on the screen).

Any other magic required to grab an activity indicator from javascript?

Ed

nschum
  • 15,322
  • 5
  • 58
  • 56
EdG
  • 31
  • 3

3 Answers3

2
target.delay(1);

target.pushTimeout(10);

target.frontMostApp().mainWindow().activityIndicators()["In progress"].waitForInvalid() == true;

target.popTimeout();

This will wait 1 second for activity indicator to appear. Then, it will wait for it to become invalid with a timeout value of 10 seconds. Substitute "In progress" for your indicator name.

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Imran_M
  • 76
  • 3
2

This is the function I've built for waiting for page loads in iOS. You can pass an optional preDelay before the function's code executes, other than that it waits for the activityIndicator object to become null for 30 seconds (trying every half second, 60 times). I've extended the UIAutomation tool to encompass this command when I tap on objects.

this.wait_for_page_load = function(preDelay) {        
    if (!preDelay) {
        target.delay(0);
    }
    else {
        target.delay(preDelay);
    }

    var done = false;
    var counter = 0;      
    while ((!done) && (counter < 60)) {
        var progressIndicator = UIATarget.localTarget().frontMostApp().windows()[0].activityIndicators()[0];
        if (progressIndicator != "[object UIAElementNil]") {
            target.delay(0.5);
            counter++;  
        }
        else {
            done = true;           
        }
    }
    target.delay(0.5);
}
  • This code is slightly different than what I was using, but it produces the same wrong results. With the exact code above, progressInidicator is always nil ([object UIAElementNil]), even though the activity indicator is spinning on screen. Again, a logElementTree of the app at the point where the activity indicator is active and spinning shows NO activity indicator. Is there any magic required to create the UIActivityIndicator to make it show up? I have tried it with and without the Accessibility Label. – EdG Aug 27 '11 at 17:17
0

The below line of code solved my problem

while(target.frontMostApp().mainWindow().activityIndicators()["In progress"].isEnabled());

its wait until the activity indicator become disable(but its take 1-2 more seconds to become disable after indicator removed from our view)

arunjos007
  • 4,105
  • 1
  • 28
  • 43