Android: specific time to find an element

how to i wait to find an element for specific time interval ?
If not found i want to execute next line of code.

Thank You,


You can use WebDriverWait:

You look for the element and if it’s not found an exception will be thrown. Catch the exception using try catch, print to console or log and the script will continue on with the test.

 // pass the driver and the number of seconds you want to wait
  WebDriverWait wd = new WebDriverWait(driver, 10);
       // Define the element you are looking for. You can use any By method you want
        By element = By.xpath("//*[@text='hello']");
        try {
        } catch (Exception e) {
            System.out.println("Element not found: " + e);
            System.out.println("Couldn't find the element, continuing with test");
        // continue test

Thank you so much :grinning: worked for me.

use the Explicit wait it will work for you

Thanks man its working now