About this question
I would like to select an webelement</select>
I would like to select an webelement</select>
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask QA Expert
Answered on Apr 26, 2022
I think using selenium.webdriver.support.ui.Select is the cleanest way for selenium select dropdown python: from selenium import webdriver from selenium.webdriver.support.ui import Select
b = webdriver.Firefox()
# navigate to the page
select = Select(b.find_element_by_id(....))
print select.options
print [o.text for o in select.options] # these are string-s
select.select_by_visible_text(....)
Using this approach is also the fastest way. I wrote fast_multiselect as an analogous function to multiselect_set_selections. On a test with 4 calls to multiselect_set_selections on lists of about 20 items each, the average running time is 16.992 seconds, whereas fast_multiselect is only 10.441 seconds. Also the latter is much less complicated.
from selenium.webdriver.support.ui import Select
def fast_multiselect(driver, element_id, labels):
select = Select(driver.find_element_by_id(element_id))
for label in labels:
select.select_by_visible_text(label)Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Step-by-step QA Testing guides from industry experts
Common QA Testing interview questions, answered
Guides, tips and career advice on QA Testing from JanBask experts.
QA Testing Automation Tester Career Path: Stages, Pay, and Where It Leads
Automation tester career path explained: stages from junior to architect, US pay, the manager vs. specialist fork, and how AI…
QA Testing Manual Tester vs Automation Tester: Differences, Skills, Pay, and Which Role Fits You
Manual tester vs automation tester: compare daily work, skills, tools, pay and career paths, then see which role fits you best.
QA Testing Automation Tester Job Demand: What the Job Data Really Says
Is automation testing in demand? See job growth, pay by title, the skills employers want, and how to move into an automation…
QA Testing How to Become a Software Tester With No Experience
No testing experience? See what BLS and O*NET say, compare manual vs automation, check entry pay, and learn the first steps to a…