5. Working with DropDown Select Operations - naveens33/selenium_python GitHub Wiki

Select is a class which is provided by Selenium to perform operations on DropDown object. This class can be found under the Selenium’s selenium.webdriver.support.ui module.
from selenium.webdriver.support.ui import Select
Declare the drop-down element as an instance of the Select class
fromaccele=driver.find_element_by_xpath("//*[@id='tf_fromAccountId']")
fromaccselect=Select(fromaccele)
Can Handle Drop Down by following types of Select Methods.
fromaccselect.select_by_visible_text("Loan(Avail. balance = $ 780)")
Types of Select Methods:
-
select_by_index(index) - Select the option at the given index counting
-
select_by_value(value) - Select all options that have a value matching the argument
-
select_by_visible_text(text) - Select all options that display text matching the argument
Refer transferfund_scenario.py file
Q&A:
How to select a value in a dropdown
By using Select class
How to get all available options
options = select.options