Hi, In Exercise 2C) "Click on each and every link on first 5 pages and check if next page is opening". It is working fine till the page No.4 but after that code throw the bellow error.
NOTE:- Project attached. Please run below code on your machine and tell me where i am wrong.
// Code for Scrolldown using javascriptExecuter allLinks= driver.findElements(By.xpath("//div[@id='rso']/div/div/div/h3/a")); lastFriend = allLinks.get(allLinks.size()-1); y= lastFriend.getLocation().y; js = (JavascriptExecutor)driver; js.executeScript("window.scrollTo(0, "+y+")"); // Print all the names links on the page.
for(int count =0;count<allLinks.size();count++){
System.out.println("Name of the Links are -- >" +allLinks.get(count).getText()); allLinks.get(count).click(); Thread.sleep(3000L); driver.navigate().back();