I am trying to download the csv file from this link with selenium: https://ourworldindata.org/grapher/annual-co-emissions-by-region and am encountering issues regarding finding the actual elements necessary to download the file. Here is my code so far:
driver.get("https://ourworldindata.org/grapher/annual-co-emissions-by-region")
frame = driver.find_element_by_id("GTM-N2D4V8S")
driver.switch_to.frame(frame)
downloadLink = driver.find_element_by_xpath("/html/body/main/figure/div/div[4]/div/nav/ul/li[4]/a")
driver.execute_script("arguments[0].click();", downloadLink)
Specifically, I am trying to find the second div underneath the element with this css selector body > main > figure > div > div.DownloadTab
, which contains the download link. Unfortunatley, while I am able to find this parent element, I am unable to find the div I am looking for. From doing research, I think that this issue might have to do with the iframe, so I am trying to switch it with the code above (although it is not working). This link may be helpful: Selenium can't find elements even if they exist
Thanks so much!