Can I select multiple options from a dropdown using Python Selenium webdriver

+1 vote
Can I select multiple options from a dropdown using Python Selenium webdriver?
Jul 31, 2019 in Selenium by Dhwani
4,997 views

For me:

Multi-select option worked by below code when I used CSS Selector-

act=ActionChains(self.drv)
WE_cmd= self.drv.find_element(By.CSS_SELECTOR,'#selenium_commands > option:nth-child(2)' )
opt=Select(self.drv.find_element(By.ID,"selenium_commands"))
opt.select_by_visible_text("Browser Commands")
act.key_down ( Keys.CONTROL ).click ( WE_cmd).key_up ( Keys.CONTROL ).perform ()

1 answer to this question.

–1 vote

Hi Dhwani, you can use following code snippet to select multiple options from a dropdown using python selenium webdriver:

driver=new firefoxdriver();
driver.get('https://www.drivezy.in/')
select = Select(driver.findElement(by.cssSelector("select[multiple='multiple']"))

select.select_by_visible_text("BMW")
select.select_by_visible_text("Saab")
select.select_by_visible_text("Mercedes")
driver.quit()
answered Jul 31, 2019 by Abha
• 28,140 points

Related Questions In Selenium

0 votes
1 answer

How can I perform multiple selection of options in a dropdown using Select class in Selenium?

Hey Priyansh, you can select multiple options ...READ MORE

answered Jul 8, 2019 in Selenium by Anvi
• 14,150 points
3,255 views
0 votes
1 answer

How can I select an option from a dropdown using Ruby Selenium Webdriver?

Hey Swasti, you can try following lines ...READ MORE

answered Aug 26, 2019 in Selenium by Anvi
• 14,150 points
4,798 views
0 votes
1 answer
0 votes
1 answer

How can I select date from a datepicker div using Selenium Webdriver?

Hey Jeevika, you can use following automation ...READ MORE

answered Jul 15, 2019 in Selenium by Abha
• 28,140 points
12,219 views
0 votes
1 answer
0 votes
1 answer

Select an item from a dropdown list using Selenium WebDriver

Use this then it will work - new ...READ MORE

answered Apr 9, 2018 in Selenium by Vardy
• 2,360 points
7,800 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,806 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,210 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,288 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,914 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP