Here is code that I am using firstly I am clicking on the button then the list of items is shown and I try to select from the list but it said that Index=0, Size=0 when I use Xpath. When I use the class_name it said "Element not Visible".
Here is code for this:
driver.findElement(By.id("add_new_item_btn")).click();
Thread.sleep(6000);
java.util.List<WebElement> listItems1 = driver.findElements(By.className("dropdown-menu"));
listItems1.get(0).click();
Here is the code in the the inspect element:
<div class="dropdown open">
<button class="btn-blue-simple btn dropdown-toggle" type="button" id="add_new_item_btn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Add
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li>
<a class="pull-left" onclick="showPopup("Add Labor Item", '/quote_items/new?item_type=labor&product_category_id=1912275102536303582&quote_id=1949426380886245765')" href="javascript:void(0)">Labor</a>
</li>
<li>
<a class="pull-left" onclick="showPopup("Add Parts Item", '/quote_items/new?item_type=part&product_category_id=1912275102796350432&quote_id=1949426380886245765')" href="javascript:void(0)">Parts</a>
</li>
<li>
<a class="pull-left" onclick="showPopup("Add Warranties Item", '/quote_items/new?item_type=warranty&product_category_id=1912275103022842850&quote_id=1949426380886245765')" href="javascript:void(0)">Warranties</a>
</li>
</ul>
</div>