title: How to click in nav-bar and choose item from a list in selenium java
body: <p>I have tried this</p>
  
  <pre><code>List &lt;WebElement&gt; navlist = driver.findElements(By.cssSelector("d-md-down-none nav navbar-nav mr-auto"));
  navlist.get(0).findElement(By.linkText("Sources")).click();
  </code></pre>
  
  <p>Below is the HTML code:</p>
  
  <pre><code>&lt;ul class="d-md-down-none nav navbar-nav mr-auto"&gt;
      &lt;li class="px-3 nav-item"&gt;
          &lt;a aria-disabled="false" href="#/sources" class="nav-link"&gt;Sources&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="px-3 nav-item"&gt;
          &lt;a aria-disabled="false" href="#/alerts" class="nav-link"&gt;Alerts&lt;/a&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Error when trying my example :</p>
  
  <pre><code>Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at Adding_new_source.New_source.main(New_source.java:53) 
  </code></pre>
  
  <p>How to click in nav-bar and choose item from a list in selenium java</p>