How to handle Bootstrap DropDown in Selenium – Session – 19



https://i.ytimg.com/vi/Tm1TeqdYrrI/hqdefault.jpg



How to handle Bootstrap DropDown in Selenium :

• How to handle different styles of bootstrap down
• Click on the given dropdown
• Get all the tags while are available under “li” tag
• Get the text of each “li//a” OR “div//a”
• Match the text and click on it

===================================================
Please subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Channel URL:
https://www.youtube.com/c/Naveen%20AutomationLabs?sub_confirmation=1
=======================================================
Follow me on my Facebook Page:
https://www.facebook.com/groups/naveenqtpexpert/

Let’s join our Automation community for some amazing knowledge sharing and group discussion. Plz join via this link:

https://t.me/joinchat/COJqZQ4enmEt4JACKLNLUg

-~-~~-~~~-~~-~-
Follow my Site/Blog: http://www.naveenautomationlabs.com
========================================================
Please watch: “Selenium & Automation Interview Preparation – By Naveen AutomationLabs”

-~-~~-~~~-~~-~- Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
https://www.youtube.com/c/Naveen%20AutomationLabs?sub_confirmation=1

Follow me on my Facebook Page:
https://www.facebook.com/groups/naveenqtpexpert/

Let’s join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
https://t.me/joinchat/COJqZUPB02r5sB73YMdXEw

Paid courses (Recorded) videos:
Java & Selenium Course: http://www.naveenautomationlabs.com/p/course-content-selenium-webdriver-is.html
API Course: http://www.naveenautomationlabs.com/p/syllabus-course-content-manual-testing.html ➡️Get Our Courses✔️
📗 Get My Paid Courses at
Paid courses (Recorded) videos:
Java & Selenium Course: http://www.naveenautomationlabs.com/p/course-content-selenium-webdriver-is.html
API Course: http://www.naveenautomationlabs.com/p/syllabus-course-content-manual-testing.html
——————————-

✔️SOCIAL NETWORKS
Facebook: https://www.facebook.com/groups/naveenqtpexpert/
Twitter: https://twitter.com/naveenkhunteta
Blog: http://www.naveenautomationlabs.com
——————————–

Support My Channel✔️Or Buy Me A Coffee
Paypal: https://paypal.me/naveenkhunteta
Google Pay: naveenanimation20@gmail.com
——————————–
✔️Thanks for watching!
देखने के लिए धन्यवाद
Благодаря за гледането
感谢您观看
Merci d’avoir regardé
Grazie per la visione
Gracias por ver
شكرا للمشاهدة

Original source


20 responses to “How to handle Bootstrap DropDown in Selenium – Session – 19”

  1. Hi, Naveen your videos are very good,
    in this video I've doubt i.e once I clicked on the dropdown button I got 14 options as you said. And I want to select Angular so here I can use
    Dynamic XPath right i.e selecting the checkbox based on Angular element na .. here I'll inspect the independent element angular and dependent element checkbox… using XPath as ……. //label[text()=' Angular']/../../..//input[@value='Angular']

  2. For the already selected options, we can't use isSelected() method. Because this method always returns false. So we have to use the li-class which changes the class name to "active" when the checkbox is selected. So we can select all the checkboxes without unselecting the already selected ones by using below logic.
    for (int i = 0; i < bsOptions.size(); i++) {

    if ((bsOptions.get(i).getAttribute("class").equalsIgnoreCase("active"))) {

    System.out.println(bsOptions.get(i).getText());

    Thread.sleep(1000);

    } else

    bsOptions.get(i).click();

    }

  3. Can't I write //ul[contains(@class,'multiselect-container')]//li//a//label[contains(text(),'Angular')] directly to select the element and perform click operation instead getting list<webElement> of label then selecting that element and performing click operation?

  4. That was really helpful….

    Can you please make one tutorial is video for Jmeter 5.0 also…?

    Please because you have got awesome ability to explain.. I love ❤ the way you elaborate something.
    Thanks in advance.

  5. Hello Naveen, what if i need to select multiple check boxes not all in the drop down and also its very difficult for me to capture the xpath of the dropdown elements as when i just come out of the dropdown list the ul gets hidden in html code

  6. Hello Naveen- I have the same scenario where I need to select multiple options from the dropdrown but when I click on the dropdrown and try to find the xpath of the elements in the dropdown, it does not show the xpath of the elements. The ul tag for me is hidden and I got it after i pressed F12 in the UI. Its very difficult for me to capture the xpath of the dropdown elements as when i just come out of the dropdown list the ul gets hidden in html code

  7. Hi Naveen,

    Hello Sir,

    Can you please assist me in Bootstrap –

    If Bootstrap dropdown has more than 15+ options and has an AutoScroll.

    How do I scroll Bootstrap in selenium?

    My mail id – mahendramungase@gmail.com

    Can you please share your mail id

    Thanks,
    Mahendra

  8. Hi Naveen, I tried your bootstrap drop down logic in the following URL
    https://www.makemytrip.com/international-flights/dubai-india-lufthansa_airlines-tickets.html
    to fetch all the cities "from" drop down.
    As you said I used the xpath as "//ul[2][@class='ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all']//li//a" .
    Actual count is 84 cities but when I execute through webdriver it displays only
    28 cities.
    Please help me to solve this issue.

Leave a Reply