title: Clicking on link one by one from the same page using selenium webdriver
body: <p>I'm trying to click on state link given url then print title of next page and go back, then click another state link dynamically using for loop. But loop stops after initial value. <br>
  My code is as below:</p>
  
  <pre><code> public class Allstatetitleclick {  
      public static void main(String[] args) {        
          WebDriver driver = new FirefoxDriver();
          driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
          driver.manage().window().maximize();
          driver.get("http://www.adspapa.com/");      
  
          WebElement catBox = driver.findElement(By.xpath("html/body/table[1]/tbody/tr/td/table/tbody/tr/td[1]/table"));
          List&lt;WebElement&gt; catValues = catBox.findElements(By.tagName("a"));
  
          System.out.println(catValues.size());
  
          for(int i=0;i&lt;catValues.size();i++){
  
              //System.out.println(catValues.get(i).getText());       
              catValues.get(i).click();
              System.out.println(driver.getTitle());
              driver.navigate().back();
  
          }
          System.out.println("TEST");
      }
  }
  </code></pre>