title: Getting child elements using WebDriver
body: <p>I've got the following HTML code:</p>
  
  <pre><code>&lt;div class="ui-selectmenu-menu" style="z-index: 1; top: 251px; left: 37px;"&gt;
      &lt;ul class="ui-widget ui-widget-content ui-selectmenu-menu-dropdown ui-corner-bottom" aria-hidden="true" role="listbox" aria-labelledby="gwt-uid-191-button" id="gwt-uid-191-menu" style="width: 270px; height: auto;" aria-disabled="false" aria-activedescendant="ui-selectmenu-item-999"&gt;
          &lt;li role="presentation" class="ui-selectmenu-item-selected"&gt;
            &lt;a href="#nogo" tabindex="-1" role="option" aria-selected="true" id="ui-selectmenu-item-999"&gt;All Applications&lt;/a&gt;&lt;/li&gt;
          &lt;li role="presentation" class=""&gt;
            &lt;a href="#nogo" tabindex="-1" role="option" aria-selected="false"&gt;Option Alpha&lt;/a&gt;&lt;/li&gt;
          &lt;li role="presentation" class="ui-corner-bottom"&gt;
            &lt;a href="#nogo" tabindex="-1" role="option" aria-selected="false"&gt;Option Beta&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  ...
  &lt;div class="ui-selectmenu-menu"...&gt;...&lt;/div&gt;
  </code></pre>
  
  <p>I'm able to get the WebElement for <code>ui-selectmenu-menu</code> like this (there are many on the page; hence, the use of <code>findElements</code>) :</p>
  
  <pre><code>List&lt;WebElement&gt; dropdowns = driver.findElements(By.className("ui-selectmenu-menu"));
  </code></pre>
  
  <p>And the <code>ul</code> below it like this:</p>
  
  <pre><code>WebElement ddChild = dropdowns.get(0).findElement(By.className("ui-selectmenu-menu-dropdown"));
  </code></pre>
  
  <p>I'm even able to grab all the <code>li</code> under the <code>ddChild</code> like this:</p>
  
  <pre><code>List&lt;WebElement&gt; ddOpts = ddChild.findElements(By.xpath("//*[@id='gwt-uid-191-menu']/li[*]"));
  </code></pre>
  
  <p>But the problem that I can't seem to figure out how to grab the text-value of the <code>&lt;a href="#nogo"...</code> tag under each <code>li</code> element.</p>
  
  <p>I'd like to be able to loop through all the <code>ddOpts</code> and grab the <code>&lt;a href="#nogo"...</code> text values and save them to an <code>ArrayList&lt;String&gt;</code>.</p>
  
  <p>So, for example, my first <code>ArrayList&lt;String&gt;</code> value would contain <code>All Applications</code>, then <code>Option Alpha</code>, then <code>Option Beta</code>, and then jump to the next <code>ul</code> element from the next <code>dropdowns</code> and do the whole process again, all while adding to the <code>ArrayList&lt;String&gt;</code>.</p>
  
  <p>I'm sure its a simple solution but I've got limited experience with Selenium WebDriver.</p>
  
  <p>Thanks!</p>
  
  <p><em>PS: Is there a simple way to grab the child of a WebElement?</em></p>