Click in a specific element of list of web elements in Java selenium
<p>I am automating a web page using cucumber and selenium in java, and I have this xpath</p>

<pre><code>      .//*[@id='chosen_motivos_investimentos_chosen']/div[1]/ul[1]
</code></pre>

<p>and inside the ul[1] I have a bunch of li, in this case I have this portion of html:</p>

<pre><code>&lt;ul class="chosen-results"&gt;
&lt;li class="active-result" style="" data-option-array-index="1"&gt;LA - Media Buying Fees ‐ Traditional&lt;/li&gt;
&lt;li class="active-result" style="" data-option-array-index="2"&gt;LL - Marketing Development&lt;/li&gt;
&lt;li class="active-result" style="" data-option-array-index="3"&gt;LQ - Media Buying Fees ‐ Digital&lt;/li&gt;
&lt;li class="active-result" style="" data-option-array-index="4"&gt;LU - Media Costs ‐ Traditional&lt;/li&gt;
&lt;li class="active-result" style="" data-option-array-index="5"&gt;LV - Advertising Production Costs ‐ Traditional&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>And I want to click in a specific li to select, this specific is given via parameter (String despesa), I have tried this:</p>

<pre><code>    Thread.sleep(2000);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[@id='chosen_motivos_investimentos_chosen']/a"))).click();
    List&lt;WebElement&gt; dropDespesa = driver.findElements(By.xpath(".//*[@id='chosen_motivos_investimentos_chosen']/div[1]/ul[1]"));
    i = dropDespesa.iterator();
    while(i.hasNext()){
        WebElement row = i.next();
        if(row.getText().equalsIgnoreCase(despesa)){
            System.out.println("Igual");
            row.click();
        }
        System.out.println(row.getText());
    }
</code></pre>

<p>But webdriver never goes inside if, and I already debugged and made sure that despesa is in fact equals row.getText()</p>