IF we have 100 links in a web page how to click on 99th link.
I'm able to find all links but unbable to click on link based on linktext. While trying below code getting elementnot visible exception.
cd.get("http://timesofindia.com");
List<WebElement> lst=cd.findElements(By.tagName("a"));
System.out.println(lst.size());
for(int i=0;i<=lst.size()-1;i++) {
if (i==99)
lst.get(i).click();
else
Instructor
Ashish Thakur Replied on 18/03/2019
You need to scroll the page before clicking that link
1> Should tht code will work??
2> Whats the reason we need to scroll the page?
Instructor
Ashish Thakur Replied on 19/03/2019
The element you want to click is not visible on the screen, to make it visible, you need to scroll the page before clicking
thanks , its working fine.Hence can be closed.