Select a value from a select element using selenium in Python
Question:
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"))))
isd.select_by_value("119")
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)
accion.move_to_element(isd).click().perform()
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.
Answers:
You can try this:
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://www.mischooldata.org/student-attendance")
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()
time.sleep(5)
Hope, it’ll be useful 🙂
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"))))
isd.select_by_value("119")
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)
accion.move_to_element(isd).click().perform()
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.
You can try this:
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://www.mischooldata.org/student-attendance")
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()
time.sleep(5)
Hope, it’ll be useful 🙂