Hi Neeru, Bootstrap dropdown isn't like traditional dropdowns as it doesn't use <select> tags, rather it uses <ul> and <li> tags to make a dropdown. So to handle bootstrap dropdown, you need to use findElements() method which will return all the options of the dropdown. Following code snippet shows how to handle a bootstrap dropdown:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class BootstrapDropdown {
public static void main(String[] args) throws InterruptedException {
FirefoxDriver driver = new FirefoxDriver();
driver.get("https://www.edureka.co");
driver.findElement(By.className("icon-Home-page-humburger-menu-01")).click();
Thread.sleep(2000);
//Dropdown items are coming in <a> tag so below xpath will get all elements and findElements will return list of WebElements
List<WebElement> list = driver.findElementsByXPath("//ul[@id='hiddencat']//li/a");
for (WebElement element : list)
{
System.out.println("Values " + element.getAttribute("innerHTML"));
}
}
}