user2398911
user2398911

Reputation: 94

UIAutomation Tests timer wait until done

I use UIAutomation test and make script, and I need in cycle select cell in my tableView and wait until it download go to another.

var target = UIATarget.localTarget();

target.frontMostApp().mainWindow().buttons()["Search"].tap();

for(i = 1; i < target.frontMostApp().mainWindow().tableViews()["Empty list"].cells().length; i++ )
{
    if(target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()[i].buttons()["Download"].isHidden)
    {
        UIALogger.logStart("HIDDEN");
        UIALogger.logPass();
    }
    else
    {
            target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()[i].buttons()["Download"].tap();
    }

}

How I can make it when download end I have another button name View and my Download is hidden. I have an alert with progress bar that shows downloading percent.

How I can stop script and wait until it downloaded something and then go to another cell. and downloaded that.

Upvotes: 1

Views: 1982

Answers (1)

rakmoh
rakmoh

Reputation: 2963

You can implement a while loop to check for the condition (e.g. alert with download progress is visible). Make sure you slow down polling for check in the while loop and also have a timeout.

Here is the sudo code:

while (target.frontMostApp().mainWindow()..<download_progress_alert>.isVisible()) {
    if (timeout) {
        <handle error>
        break;
    }

    //Slowdown polling
    UITarget.delay(<duration in seconds>);
}

Upvotes: 3

Related Questions