title: How to check all elements in a <ul> list using Selenium WebDriver?
body: <p>Is it possible to loop through all the <code>li</code> elements of the <code>&lt;ul&gt; &lt;/ul&gt;</code>. Let's say I have an unknown number of <code>li</code> elements, so one way to loop through them would be to impose a <code>for</code> loop with a maximum possible number of <code>li</code>s, say 100, and impose <code>try and catch</code>. </p>
  
  <pre><code>try{
  for (int i=0; i&lt;100; i++) {
   driver.findElement(By.xpath("//div[@id='...']/ul/li[i]"));
  }
  }
  catch {...}
  </code></pre>
  
  <p>However, it does not recognize the <code>i</code> index? How can I make it recognize it?</p>
  
  <p>Is there any better way?</p>