title: Selenium Webdriver - How to select element in CSS Menu
body: <p>I do not know how to click a menu item on a CSS dropdown menu.
  The structure of the menu looks like this:</p>
  
  <pre><code>    &lt;ul id="nav" class="clearfix" role="navigation"&gt;
      &lt;li&gt;
      &lt;li class="navMenu navActive"&gt;
                &lt;a href="/test.user/beratung/wie-ich-sie-unterstuetze/"&gt;Allfinanzberatung&lt;/a&gt;
           &lt;ul class="subMenu" role="navigation"&gt;
               &lt;li class=" subMenuPoint"&gt;
                  &lt;div class="left"&gt;
                         &lt;a class="right" href="/test.user/beratung/wie-ich-sie-unterstuetze/"&gt;Wie ich Sie unterstütze&lt;/a&gt;    &lt;- I want to Select this Menu Point
                  &lt;/div&gt;
                &lt;/li&gt;
           &lt;/ul&gt;
      &lt;li class=" subMenuPoint"&gt;
      &lt;li class=" subMenuPoint"&gt;
      &lt;li class="last subMenuPoint"&gt;
      &lt;/ul&gt;
  </code></pre>
  
  <p>I've tried it with the following code but it doesn't work: (<code>Eclipse Junit</code>)</p>
  
  <pre><code>WebElement elems=driver.findElement(By.linkText("Wie ich Sie unterstütze"));//Menu Item
  WebElement elems1=driver.findElement(By.xpath("//li[@nav']/a"));//Menu
  Actions builder = new Actions(driver); 
  Actions hoverOverRegistrar = builder.moveToElement(elems1);
  hoverOverRegistrar.perform();
  elems.click();//at last Menu Item Click
  </code></pre>
  
  <hr>
  
  <p>First of all, thank you all,</p>
  
  <p>but unfortunately it still does not work properly.
  here is again the code for the menu.</p>
  
  <pre><code>&lt;ul id="nav" class="clearfix" role="navigation"&gt;
    &lt;li class="navMenu"&gt;
      &lt;a href="/test.user/beratung/wie-ich-sie-unterstuetze/"&gt;beratung&lt;/a&gt;
      &lt;ul class="subMenu" role="navigation"&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/beratung/wie-ich-sie-unterstuetze/"&gt;Wie ich Sie unterstütze&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/beratung/wie-ich-sie-berate/"&gt;Wie ich Sie berate&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/beratung/produktwelt/"&gt;Produktwelt&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/beratung/auszeichnungen/"&gt;Auszeichnungen&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/beratung/premium-partner/"&gt;Premium-Partner&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class="last subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/beratung/ihr-allfinanzcheck/"&gt;Ihr Allfinanzcheck&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;img alt="" src="/test.user/javax.faces.resource/pic_bg_main_menu_separator.png.xhtml?ln=images/frontend/menus" /&gt;
    &lt;/li&gt;
    &lt;li class="navMenu"&gt;
      &lt;a href="/test.user/karriere/ihre-perspektiven/"&gt;Karriere&lt;/a&gt;
      &lt;ul class="subMenu" role="navigation"&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/karriere/ihre-perspektiven/"&gt;Ihre Perspektiven&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/karriere/ihr-neuer-beruf/"&gt;Ihr neuer Beruf&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/karriere/ihr-karrierefahrplan/"&gt;Ihr Karrierefahrplan&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/karriere/ihr-karrierecheck/"&gt;Ihr Karrierecheck&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/karriere/was-andere-sagen/"&gt;Was andere sagen&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/karriere/auszeichnungen/"&gt;Auszeichnungen&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class=" subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/karriere/freie-stellen/"&gt;Freie Stellen&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
        &lt;li class="last subMenuPoint"&gt;
          &lt;div class="left"&gt;
            &lt;a class="right" href="/test.user/karriere/im-falschen-film/"&gt;Führen Sie selbst Regie&lt;/a&gt;
          &lt;/div&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>This code selects me the fourth element so "karriere" thats good <code>driver.findElement(By.cssSelector("#nav &gt; li:nth-child(4) a")).click();</code></p>
  
  <p>But unfortunately I could not select the second element of it -> Karriere -> Ihr neuer Beruf</p>
  
  <p>I try this but it dosnt work </p>
  
  <pre><code>driver.findElement(By.cssSelector("#nav &gt; li:nth-child(4) li:nth-child(2) a")).click();
  </code></pre>
  
  <p>What is the error?</p>