How to “wait to activity” using Appium, on begin and during test itself?

前端 未结 7 1559
挽巷
挽巷 2020-12-31 04:06

I\'m starting an already installed app using appium.

After my driver is initialized. How do I make it poll-wait till certain activity is displayed?

I saw onl

7条回答
  •  情话喂你
    2020-12-31 05:03

    You can use the following code to poll the current activity every second. If you want to reduce polling time you can reduce sleep time to 500 and wait*2 :

    public void waitForActivity(String desiredActivity, int wait) throws InterruptedException
    {
        int counter = 0;
        do {
            Thread.sleep(1000);
            counter++;
        } while(driver.currentActivity().contains(desiredActivity) && (counter<=wait));
    
        log("Activity appeared :" + driver.currentActivity(), true);
    }
    

提交回复
热议问题