0

I am trying to automate downloading files from a website, and am having an issue with a list box contained on the page. Once I submit the form, a window pops up saying that I never selected the option value in the list box, i.e. the option value does not remain selected once I submit. Here is my code below. Any help? Please and thanks

from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
actionChains = ActionChains(driver)
driver.get("http://www.ncdc.noaa.gov/has/HAS.FileAppRouter?datasetname=6500&subqueryby=STATION&applname=&outdest=FILE")
stations = Select (driver.find_element_by_name('stations'))
stations.select_by_value('KLWX')
#radar = driver.find_elements_by_class_name('dataset-select')
radar = driver.find_elements_by_class_name('dataset-select')
for x in range(0,len(radar)):
    if radar[x].is_displayed():
        radar[x].click()
select = Select (driver.find_element_by_name('begyear'))
select.select_by_value('2012')
select = Select(driver.find_element_by_name('begmonth'))
select.select_by_visible_text('06') 
select = Select(driver.find_element_by_name('begday'))
select.select_by_visible_text('30')
select = Select(driver.find_element_by_name('endyear'))
select.select_by_value('2012')
select = Select(driver.find_element_by_name('endmonth'))
select.select_by_visible_text('07')
select = Select(driver.find_element_by_name('endday'))
select.select_by_visible_text('01')
element = driver.find_element_by_name('emailadd')
element.send_keys("[email protected]")
driver.find_element_by_css_selector("input[type=submit]").click() 

1 Answer 1

1

It's just that you are clicking the wrong element - it should the button, not the input. Replace:

driver.find_element_by_css_selector("input[type=submit]").click() 

with:

driver.find_element_by_css_selector("button[type=submit]").click()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.