title: How to use to use assert in Selenium WebDriver for lists
body: <p>I am trying to verify the months displayed on the Facebook login page using Assert.</p>
  <p>However, the output I am getting is not correct.</p>
  <p>Here is the code:</p>
  <pre><code>public class DropDown3 {
  
      @Test
      public void selectByvalue() throws InterruptedException{
  
          WebDriver driver = new FirefoxDriver();
          driver.get(&quot;https://www.facebook.com/&quot;);
          driver.manage().window().maximize();
          WebElement month_dropdown= driver.findElement(By.id(&quot;month&quot;));
          Select month_dd = new Select(month_dropdown);
  
          List&lt;WebElement&gt; month_list = month_dd.getOptions();
          int total_months = month_list.size();
          System.out.println(&quot;Total month Count is = &quot; + total_months);
  
          String[] exp = {&quot;Month&quot;, &quot;JAN&quot;, &quot;FEB&quot;, &quot;MAR&quot;, &quot;APR&quot;, &quot;MAY&quot;, &quot;JUN&quot;, &quot;JUL&quot;, &quot;AUG&quot;, &quot;SEP&quot;, &quot;OCT&quot;, &quot;NOV&quot;, &quot;DEC&quot;};
  
          for (WebElement ele: month_list) {
              for(int i=0; i&lt;exp.length; i++) {
                  if(ele.getText().equals(exp[i])) {
                      System.out.println(&quot;Matched &quot;);
                  }
              }
          }
      }
  </code></pre>