title: How can I programmatically download Tableau csv file from website with Python?
body: <p>I am attempting to download the data from the following site programmatically with Python: <a href="https://health.wyo.gov/publichealth/infectious-disease-epidemiology-unit/disease/novel-coronavirus/covid-19-testing-data/" rel="nofollow noreferrer">https://health.wyo.gov/publichealth/infectious-disease-epidemiology-unit/disease/novel-coronavirus/covid-19-testing-data/</a> </p>
  
  <p>At the bottom right of the Tableau view there are 3 buttons: <em>Share, Download, and Full Screen</em>. After clicking <em>Download</em>, you are then taken to another pop up. I am then wanting to select <em>Crosstab</em> that then takes you to another pop up where I want to select <em>Positivity</em> and finally, <em>Download</em> which provides a csv. </p>
  
  <p>I have essentially managed to navigate through some of the iframes but am a little lost on where to click since the buttons do not include id/link.</p>
  
  <p>Below is some code from one approach:</p>
  
  <pre><code>from selenium import webdriver
  
  url = 'https://public.tableau.com/profile/melissa.taylor#!/vizhome/WyomingCOVID-19TestingDataDashboard/Dashboard1'
  
  driver = webdriver.Chrome()
  driver.get(url)
  #elem = driver.switch_to.frame(driver.find_element_by_xpath('//iframe[contains(text(), "googletagmanager"]'))
  try:
      time.sleep(4)
      iframe = driver.find_elements_by_tag_name('iframe')[0]
      driver.switch_to.default_content()
  
      driver.switch_to.frame(iframe)
      driver.find_elements_by_tag_name('iframe')
      #driver.find_element_by_id('download-ToolbarButton').click()
  
      print(driver.page_source)
  finally:
      driver.quit()
  </code></pre>
  
  <p>Below is the HTML that displays the 3 buttons from the Tableau page.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="tab-nonVizItems tab-fill-right hideLabels"&gt;&lt;div class="tabToolbarButton tab-widget undo disabled" role="button" data-tb-test-id="undo-ToolbarButton" id="undo-ToolbarButton" aria-disabled="true" tabindex="-1" style="user-select: none; -webkit-tap-highlight-color: transparent;" title="Undo"&gt;&lt;span class="tabToolbarButtonImg tab-icon-undo"&gt;&lt;/span&gt;&lt;span class="tabToolbarButtonText"&gt;Undo&lt;/span&gt;&lt;/div&gt;&lt;div class="tabToolbarButton tab-widget redo disabled" role="button" data-tb-test-id="redo-ToolbarButton" id="redo-ToolbarButton" aria-disabled="true" tabindex="-1" style="user-select: none; -webkit-tap-highlight-color: transparent;" title="Redo"&gt;&lt;span class="tabToolbarButtonImg tab-icon-redo"&gt;&lt;/span&gt;&lt;span class="tabToolbarButtonText"&gt;Redo&lt;/span&gt;&lt;/div&gt;&lt;div class="tabToolbarButton tab-widget revert disabled" role="button" data-tb-test-id="revert-ToolbarButton" id="revert-ToolbarButton" aria-disabled="true" tabindex="-1" style="user-select: none; -webkit-tap-highlight-color: transparent;" title="Reset"&gt;&lt;span class="tabToolbarButtonImg tab-icon-revert"&gt;&lt;/span&gt;&lt;span class="tabToolbarButtonText"&gt;Reset&lt;/span&gt;&lt;/div&gt;&lt;div class="tabToolbarButton tab-widget share" role="button" data-tb-test-id="share-ToolbarButton" id="share-ToolbarButton" tabindex="-1" style="user-select: none; -webkit-tap-highlight-color: transparent;" title="Share"&gt;&lt;span class="tabToolbarButtonImg tab-icon-share"&gt;&lt;/span&gt;&lt;span class="tabToolbarButtonText"&gt;Share&lt;/span&gt;&lt;/div&gt;&lt;div class="tabToolbarButton tab-widget download" role="button" data-tb-test-id="download-ToolbarButton" id="download-ToolbarButton" tabindex="-1" style="user-select: none; -webkit-tap-highlight-color: transparent;" title="Download"&gt;&lt;span class="tabToolbarButtonImg tab-icon-download"&gt;&lt;/span&gt;&lt;span class="tabToolbarButtonText"&gt;Download&lt;/span&gt;&lt;/div&gt;&lt;div class="tabToolbarButton tab-widget enterFullscreen" role="button" data-tb-test-id="toggle-fullscreen-ToolbarButton" id="toggle-fullscreen-ToolbarButton" tabindex="-1" style="user-select: none; -webkit-tap-highlight-color: transparent;" title="Full Screen"&gt;&lt;span class="tabToolbarButtonImg tab-icon-enterFullscreen"&gt;&lt;/span&gt;&lt;span class="tabToolbarButtonText"&gt;Full Screen&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
              &lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="tab-ReactView tab-toolbar-dialoghost"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks for your help!!</p>