I'm trying to download a csv from this website, by using selenium to click on the "download data" button from Python using this code:
driver = webdriver.Chrome(executable_path=r'/usr/local/bin/chromedriver')
URL = 'https://www.stats.govt.nz/experimental/covid-19-data-portal'
driver.get(URL)
element = WebDriverWait(driver, 15).until(
EC.presence_of_element_located((By.ID, "download_data-show"))
)
# Or this:
# element = WebDriverWait(driver, 15).until(
# EC.presence_of_element_located((By.XPATH, '//*[@id="download_data-show"]'))
# )
element.click()
This is the html code I get when I inspect the button:
<button id="download_data-show" class="btn btn-modal action-button shiny-bound-input" type="button"> Download data </button>
When I run the python code, I'm getting a TimeoutException and when I try with an implicit wait of 30 seconds, I get the following error:
NoSuchElementException: no such element: Unable to locate element: {"method":"link text","selector":"Download data"}
(Session info: chrome=84.0.4147.135)
Any ideas as to why the element can't be found?