Select a value from a select element using selenium in Python


this is my first time using selenium, and I have trouble.

I am trying to access this website, open the ISD dropdown, and select the option "Wayne RESA (82)," which is the value 119.

I have this code

isd = Select(WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.ID,"isds")))) 

But it is not working, and I also tried to click the dropdown menu first using the next code.

isd = WebDriverWait(browser, 10).until(EC.visibility_of_element_located((By.ID,"isds")))   
accion = ActionChains(browser) 
elect_isd = Select(isd) select_isd.select_by_value('119')

The previous code opens the dropdown menu, but again nothing more happens.

Any help is well received. Thanks.

Asked By: Victor



That website does not have the elements you think it has:

enter image description here

Notice how the entry for Alpena-Motnmorency-Alcona ESD (04) is not even in a .

Answered By: Shaheed Haque

You can try this:

import time
from selenium import webdriver
from import By
from import WebDriverWait
from import expected_conditions as EC

driver = webdriver.Chrome()


isd = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID,"isds")))
driver.find_element(by=By.XPATH, value='//*[@id="reports-container"]/div/div[1]/div[4]/div[1]/span/div/button').click()
driver.find_element(by=By.XPATH, value='//*[@id="reports-container"]/div/div[1]/div[4]/div[1]/span/div/ul/li[57]/a/label').click()

Hope, it’ll be useful 🙂

Answered By: Ajeet Verma
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.