@amodh
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 {
wd.until(ExpectedConditions.presenceOfElementLocated(element));
} catch (Exception e) {
System.out.println("Element not found: " + e);
System.out.println("Couldn't find the element, continuing with test");
}
// continue test
}