Select an item from the selenium drop-down list


I want to select an item from a dropdown using selenium. The project uses jsf, primefaces, spring. The dropdown html appears in a list. Like.

<div id="mydropdown">

Since i want to select a random value inside of hardcoding the nth <li> to be selected, I wrote the code as

String selectItem ="03";

But the output is:

[ <li>03<li>,
  <li>30</li> ]

It selects all <li> items containing 3. I does not consider the zero before the 3.

My Question is: How do get the output like [ <li> 03 </li> ] only?

Check for an exact match:

driver.findElement(By.xpath("//div/ul/li[.='" + selectItem + "']"));