title: Python Selenium driver.find_element_by_xpath can't find element within iframe
body: <p>I'm trying to crawl a website for sports statistics, and realised all of the important data is inside an iframe. I use driver.switch_to.frame() to switch to the iframe and that doesn't throw any errors.</p>
  <pre><code>frame1 = '//iframe[@src=&quot;reallylongsource&quot;]'
  
  
   driver.switch_to.frame(driver.find_element_by_xpath(frame1))
  </code></pre>
  <p>But then when I try to access the information inside the iframe,</p>
  <pre><code>selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: .//div[@class=&quot;classname&quot;]
  </code></pre>
  <p>is raised. I can see that the element is there in the HTML but I can't find it with selenium. I've tried locating it with CSS selector as well with no success.</p>
  <p>I'm quite sure it's the correct iframe as well. I've tried finding it both with the xpath and by tag name and they were the same iframe.</p>
  <p>When I print</p>
  <pre><code>print(driver.find_element_by_xpath(frame1).text)
  </code></pre>
  <p>I only get blank space</p>
  <p>I've been butting my head against the wall for quite a while now and can't figure it out!</p>
  <p>It seems like I'm able to switch to the correct iframe, but selenium can't find any information within it.</p>