Search code examples
androidappium

Appium, how to wait an action or behavior


i´d like to know how to do a "wait" until some action be completed, like i have this app with a splash screen and i need to wait the splash to press a button ("Done"), how do i do that? i tried this one, but gives me an error:

AndroidDriver driver = capabilities();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        WebDriverWait wait = new WebDriverWait(driver, 20);
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//android.widget.TextView[contains(@text,'Done')]")));

        driver.findElementByXPath("//android.widget.TextView[text@='Done']");
        driver.findElementByXPath("//android.widget.TextView[text@='Got it']");
        driver.findElementByAndroidUIAutomator("new UiScrollable(new USelector()).scrollIntoView(text(\"World Music\"));");
        driver.findElementByXPath("//android.widget.TextView[text@='SKIP']");

Thank you


Solution

  • i got the solution, creating a wait method

        WebDriverWait wait = new WebDriverWait(driver, 10);
        wait.until(ExpectedConditions.textToBePresentInElement(By.xpath("//*[@text='Done']"), "Done"));