I want to switch to an iframe which contains some links in it. I need to switch to that iframe and click the links one by one. Here is my code,
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get("http://timesofindia.indiatimes.com/home");
WebDriverWait wait = new WebDriverWait(driver,200);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("riShop")));
driver.switchTo().frame("riShop");
List<WebElement> lst = driver.findElements(By.tagName("a"));
for(int i = 0; i < lst.size(); i++) {
lst.get(i).click();
driver.navigate().back();
}
}
In the above code only the first link gets clicked and then I get an exception like "unable to locate the next element" NoSuchException
How do I fix this?