Friday, August 26, 2016

Bootstrap Dropdown Example for Selenium


The .dropdown class is used to indicate a dropdown menu.

Use the .dropdown-menu class to actually build the dropdown menu.


  1. if Html option is disable then how to verify in selenium that option is disabled

  2. Sir from this below code i'm not able to print the options of dropdown

    public class DropDownOption
    public WebDriver driver=new FirefoxDriver();

    public void openURL()
    System.setProperty("webdriver.firefox.marionette", "D:\\Mahesh\\Library\\geckodriver-v0.14.0-win64\\geckodriver.exe");


    List dropdown=driver.findElements(By.xpath("//div[@id='glsctl00_mainContent_ddl_originStation1_CTNR']//ul//li//a"));

    for(int i=0;i<dropdown.size();i++)
    WebElement drp=dropdown.get(i);

    String innerhtml=drp.getAttribute("innerhtml");

    System.out.println("city from -- "+innerhtml);
    public static void main(String[] args)
    DropDownOption obj=new DropDownOption();



    1. Hi Mahesh Sheelvant

      code is correct please update,

      "innerhtml" into "innerHTML"

      String innerhtml=drp.getAttribute("innerHTML");

  3. Thanks for Sharing this blog, it is very helpful to us. A good information to learners and each and every topic is easy to understand ...... Selenium Online Training

  4. Excellent ! I am truly impressed that there is so much about this subject that has been revealed and you did it so nicely.
    Selenium Training in Chennai

  5. Very nice video on bootstrap dropdown. On Ie browser, bootstrap dropdown is working using xpath but it diaappers very fast.

    How to give more time on bootstrap dropdown once it appears?

  6. hi, it was also help ful for people working in python. I create code for python3.x and it worked 100%.
    ####Python Code Start
    from selenium import webdriver
    driver = webdriver.Firefox()
    dd_menu = driver.find_elements_by_xpath('//ul[@class="dropdown-menu"]//li/a')

    for Element in dd_menu:
    ElementValue= Element.get_attribute("innerHTML")
    print ("Value for DropDown is ------->" + ElementValue )
    if ElementValue.find('JavaScript') != -1:
    #print (ElementValue)
    #### Python Code End

  7. Thank you.Well it was nice post and very helpful information on selenium Online course Hyderabad

  8. It Great Selinium Blogger. its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    selenium Online Training Hyderabad

  9. This is one awesome blog article. Much thanks again. selenium Online Training Bangalore

  10. Thanks for the informative article. This is one of the best resources I have found in quite some time. Once Again Thanks for Sharing this Valuable Information i like this i Can Share this with My Friend Circle.
    Selenium Training in Noida
    Selenium Course in Noida

  11. I really enjoy the blog.Much thanks again. Really Great selenium Online Training Bangalore

  12. Selenium Training is one of the most powerful open source automation tool for web application testing (even we can say acceptance testing for web application) which lets you automate operations like — type, click, selection from a drop down etc of a web page. Primarily developed in Java Script and browser technologies such as DHTML and Frames and hence supports all the major browsers on all the platforms.

  13. Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. This paragraph gives clear idea for the new viewers of blogging, Thanks you. You’re doing a great job Man, Keep it up.
    selenium Training in Delhi

  14. This comment has been removed by the author.

  15. Thanks for Sharing This Valuable Information with Us.
    Selenium Training in Gurgaon

  16. We at COEPD provides the best web Designing course in Hyderabad. Your search to learn web designing technology ends here at COEPD. Here, we are an established training institute who have trained more than 10,000 participants in all streams. We will help you to convert your passion to learn into an enriched learning process. At COEPD, we provide finest web designing technology covering Photoshop, HTML, CSS, HTML5, CSS3, JavaScript, Boot Strap, and JQuery. We train participants to be solution providers and creative engineers.

  17. This is one of the best resources I have found in quite some time. Once Again Thanks for Sharing this Valuable Information.
    Selenium Training in Hyderabad