title: How to compare value from the table data and click in selenium
body: <p>I am working on a form where I am passing a value and selenium needs to compare that value with the table data and select it. Since the table data is dynamic not sure how to approach. Please advise</p>
  
  <p>I tried the below:</p>
  
  <pre><code>public static void awb_origin_dest(String airport_name){
      for(int i=0;i&lt;50;i++){
  
         List&lt;WebElement&gt; ele=driver.findElements(By.tagName("td"));
         for(int j=0;j&lt;ele.size();j++) {
             String listOfValues = ele.get(j).getText();
             //System.out.println(listOfValues);
             if (listOfValues.contains(airport_name)) {
                 Actions actions = new Actions(driver);
                 actions.doubleClick(ele.get(j)).perform();
                 break;
             } else {
                 continue;
             }
         }
         driver.findElement(By.id("f2ListEnquiry_table_next")).click();
      }
  }
  </code></pre>
  
  <p>If I pass value which exists in first few pages I am able to get the required but the loop does not get end and gives the exception as:</p>
  
  <blockquote>
    <p>org.openqa.selenium.NoSuchElementException: Unable to find element
    with css selector == #f2ListEnquiry_table_next</p>
  </blockquote>
  
  <p>Please tell if this is right approach or something else should be tried.</p>