title: Get index of row in table by condition in Selenium
body: <p>I have a question regarding iterating through tables in webdriver.
  I want to get the current index of row that contains cell with conditional link.
  But the result is always the index of first row of table instead of expected row. 
  The test method is listed below. </p>
  
  <pre><code>public boolean viewDetailsOfOccasion(String occasionDate) { 
  WebElement ocassionsTable = (new WebDriverWait(Driver.getDriver(), 5)).until(ExpectedConditions.presenceOfElementLocated(By.tagName("table")));
      List&lt;WebElement&gt; tableRows = ocassionsTable.findElements(By.tagName("tr"));
          for (int i = 0; i &lt; tableRows.size(); i++) {
              List&lt;WebElement&gt; tableCols = tableRows.get(i).findElements(By.xpath("//td/div/a"));
                  for (int j = 0; j &lt; tableCols.size(); j++) {
                  if (tableCols.get(j).getText().equals(occasionDate)) { 
                          System.out.println(i);
                          return true;
                          }
                      }
                  }
          return false;
      }
  </code></pre>
  
  <p>What is wrong in this implementation?</p>