Handle dropdown in selenium using python

In this post, we will see how to handle drop down webelement in Selenium and python


Install python on windows

Chose from popular python editors

Selenium tests in python

A dropdown DOM may look like this

First identify the select element

then use options method to get list of options available and select an option by using available methods as

In selenium with python, we need to import the Select class

from selenium.webdriver.support.ui import Select

If you want to select an option directly without using the Select class, you can achieve it by using xpath [get the tag ‘select’ and then it’s child tag ‘option’], as


Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our facebook:qavalidation.com, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *