I\'m trying to select an option from a drop-down that doesnt populate until the locator has been clicked. This is what I see in Firebug:
div class=\"selectize-i
Follow the below steps to select an item under div tag:
You have to use collections object to store all child elements which are stored under same tag. For Ex if you have below HTML structure:
- 2000
- 2001
- 2002
- 2003
- 2004
Write below selenium code:
List lst = driver.findElements(By.xpath());
//In this case it is //div[@id='Year']/div/ul/li
System will store all child elements in the list then you can select any element by index method using
lst.get().click();
if you do not want to find using index but text use Iterator interface to find the element from the collection then click on that element:
Iterator it = lst.iterator();
while (it.hasNext()) {
WebElement wb = it.next();
if(wb.getText().equals()) {
wb.click();
break;
}
}