I am using:
driver.manage().timeouts().implicitlyWait(180, TimeUnit.SECONDS);
But it still fails continuously for the below element
driver.findElement(By.id("name")).clear();
driver.findElement(By.id("name")).sendKeys("Create_title_01");
I have added wait code:
for (int second = 0;; second++) {
if (second >= 120) fail("timeout");
try { if (isElementPresent(By.id("name"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}
Shouldn't implicit wait take care of waiting till an element is found?
Also would it be better if I use Explicit wait instead of the code I have added that has Thread.sleep()?