Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS UIAutomation UIAActivityIndicator

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

like image 614
EdG Avatar asked Jan 19 '26 20:01

EdG


2 Answers

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);
}
like image 132
Scott Gillenwater Avatar answered Jan 21 '26 12:01

Scott Gillenwater


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.

like image 37
Imran_M Avatar answered Jan 21 '26 11:01

Imran_M