0

I'm trying to click on a button using Selenium with Python, however the button does not appear on Page Source and thus, the instantiated driver cannot find it. Here is the link I am accessing: https://data.ntsb.gov/carol-main-public/query-builder?month=6&year=2021

And the button I want to click is "Download Summary (CSV)", which is located at the end of the page.

I have already googled this kind of trouble but I haven't found a possible solution so far.

My attempt was to find the button directly by using the following commands, but it returns a NoSuchElementException:

element = driver.find_element_by_id('exportSummaryButton')
element.click()

This exception triggered me the intuition that the page source differs from what I see on Devtools and this is exactly what happens.

Thanks in advance!

  • Show what you have tried – DonnyFlaw Jul 12 '22 at 11:45
  • @DonnyFlaw I have just edited my question with my attempt. Thanks – Pedro Crespo Jul 12 '22 at 11:59
  • Since button located inside shadow-root you need to use [specific approach](https://stackoverflow.com/questions/37384458/how-to-handle-elements-inside-shadow-dom-from-selenium). Or it's better to use API-request to download file – DonnyFlaw Jul 12 '22 at 12:18
  • I will try the approach described in the link! Regarding the API-Request, I'm not sure what the endpoint should be... could you please provide more details? Thank you! – Pedro Crespo Jul 12 '22 at 12:24
  • You need to execute API request to https://data.ntsb.gov/carol-main-public/api/Query/FileExport – DonnyFlaw Jul 12 '22 at 13:13

0 Answers0