Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

How to Handle Bootstrap Dropdown in Selenium WebDriver?

Category: Selenium WebDriver

The bootstrap dropdown is enhanced part of dropdown where you will deal with UL and LI tag of HTML.

List list = driver.findElementsByXPath(""//ul[@class='dropdown-menu']//li/a"");
// We are using enhanced for loop to get the elements
for (WebElement ele : list)
{
// for every elements it will print the name using innerHTML
System.out.println(""Values "" + ele.getAttribute(""innerHTML""));
// Here we will verify if link (item) is equal to Java Script
if (ele.getAttribute(""innerHTML"").contains(""JavaScript"")) {
// if yes then click on link (iteam)
ele.click();
// break the loop or come out of loop
break;
}

Leave a Reply

Your email address will not be published. Required fields are marked *