Select (used for Drop-down)

When there’s a select tag, you should most likely use the Select class in selenium.

Example site: https://demo.automationtesting.in/Register.html

# find the element that has select tag
skills = driver.find_element(By.ID, 'Skills')

# usage of select class
select = Select(skills)
select.select_by_value("Analytics")

below is the full example.

import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

driver = webdriver.Chrome()
driver.get("https://demo.automationtesting.in/Register.html")
driver.implicitly_wait(5)
# find the element that has select tag
skills = driver.find_element(By.ID, 'Skills')

# usage of select class
select = Select(skills)
select.select_by_value("Analytics")

time.sleep(6)
driver.quit()
Updated on