title: SecurityError: Permission denied to access property "document" on cross-origin object error clicking on download link in iframe using Selenium Python
body: <p>I am working on an automation project and I am trying to download a pdf from a website. The website only contains the pdf but the file type of the webpage is HTML. The pdf is displayed using PDF.js and the PDF.js viewer is also in an iframe.</p>
  <p>When I tried to click the element using browser javascript, i was returned with a security error relating to cross site scripting.</p>
  <pre><code>SecurityError: Permission denied to access property &quot;document&quot; on cross-origin object
  </code></pre>
  <p>I would like to download the pdf from my script, written in python, using selenium. When I try this:</p>
  <pre><code>driver.find_element_by_id('download').click()
  </code></pre>
  <p>No results are produced, the download button doesn't get clicked even though I have switched focus to the iframe in selenium.</p>
  <p>Does anybody know a solution how to download the pdf?</p>