Not able to click on all the links in Selenium Webdriver.Only the first link gets clicked
Posted
by
Kiran
on Stack Overflow
See other posts from Stack Overflow
or by Kiran
Published on 2014-08-22T10:17:22Z
Indexed on
2014/08/22
10:19 UTC
Read the original article
Hit count: 179
.i want to go to a frame in which some links are there....Once I come in to a fram.i want to click all the links one by one..using webdriver...below is the code i have written.plz suggest me
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(inti=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 exception like..unable to locate the next element.....NoSuchException plz suggest me something about it...
© Stack Overflow or respective owner