Home > Blockchain >  Having trouble selecting dropdown with Python Selenium
Having trouble selecting dropdown with Python Selenium

Time:01-22

Greetings everyone way more intelligent than I am. I'm currently trying my hand at web scraping in order to automate some searches for work. The website that I'm scraping is here: enter image description here

Any helpful hints, code, or even a book that might provide some guidance would be greatly appreciated. Thanks!

CodePudding user response:

wait=WebDriverWait(driver,60)     
driver.get("https://propertyinfo.revenue.wi.gov/WisconsinProd/search/advancedsearch.aspx?mode=advanced")
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#btAgree"))).click()
box=Select(wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#sCriteria"))))
box.select_by_index(1)

To simply grab that box and select any element you can use the following wait for the element. As well as clicking the agree button beforehand.

Imports:

from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC
  •  Tags:  
  • Related