I'm using Selenium 2.0 web driver. My script fails occasionally whenever I try locating something in my page. It throws an exception:
Unable to locate element: {"method":"id","selector":"username"};
part of my code:
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebElement userName = driver.findElement(By.id("username"));
userName.clear();
userName.sendKeys("admin");
It passes successfully sometimes with the same code. I don't understand what's happening.