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

0 votes
Can I select multiple options from a dropdown using Python Selenium webdriver?
Jul 30, 2019 in Selenium by Dhwani
1,635 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.

0 votes

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 30, 2019 by Abha
• 27,950 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,110 points
1,033 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,110 points
1,079 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
5,070 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,520 points
4,025 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31 in Selenium by Sri
• 2,970 points
4,972 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,890 points
2,912 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 2 in Selenium by Sri
• 2,970 points
3,344 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
• 27,950 points
8,074 views