title: Verify list elements by Selenium WebDriver
body: <pre><code>WebElement select = myD.findElement(By.xpath("//*[@id='custfoodtable']/tbody/tr[2]/td/div/select"));
  List&lt;WebElement&gt; allOptions = select.findElements(By.tagName("option"));
  for (WebElement option : allOptions) {
      System.out.println(String.format("Value is: %s", option.getAttribute("value")));
      option.click();
      Object vaLue = "Gram";
      if (option.getAttribute("value").equals(vaLue)) {
          System.out.println("Pass");
      } else {
          System.out.println("fail");
      }
  }
  </code></pre>
  
  <p>I can verify one element in a list, but there are like 20 elements in a dropdown I need to verify and I do not want to use above logic 20 times. Is there any easier way to do it?</p>