title: Take a screenshot of an iFrame using pyside
body: <p>I have an issue taking screenshots of a Google-translated page. The below script is working fine (takes a screenshot) <em>without</em> Google translate: </p>
  
  <pre><code>class Render(QWebPage):
      def __init__(self, url):
          self.web_page = QWebPage()
          self.finished = False
          s = self.web_page.settings()
          s.setAttribute(QWebSettings.JavascriptCanOpenWindows, False)
          s.setAttribute(QWebSettings.PluginsEnabled, True)
          self.web_page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
          self.web_page.loadFinished.connect(self._loadFinished)  
          self.web_page.mainFrame().load(QUrl(url))
  
      def _loadFinished(self, result):
          frame = self.web_page.mainFrame()
          size = frame.contentsSize()
          size.setWidth(1000)
          self.web_page.setViewportSize(size)
          image = QImage(self.web_page.viewportSize(), QImage.Format_ARGB32)
          painter = QPainter(image)
          frame.render(painter)
          painter.end()
          self.filepath="screenshot_name.jpg"
          image.save(self.filepath)
          self.finished = True
  
  def run(url):
      app=QApplication.instance()
      if not app:
          app = QApplication(sys.argv)
      r = Render(url)
      while not r.finished:
          app.processEvents()
          time.sleep(0.01)
      return r.filepath
  
  news_url="http://arabic-media.com/arabicnews.htm"
  news_url_google_translate = "http://translate.google.com/translate?hl=en&amp;sl=auto&amp;tl=en&amp;u="+news_url
  run(news_url_google_translate)
  </code></pre>
  
  <p>But I need to take a screenshot of the translated page. Google translated page creates iframes. So I used the following to take a screenshot of the inner frame (name=c): </p>
  
  <pre><code>frame = self.web_page.mainFrame().childFrames()[0]
  </code></pre>
  
  <p>Unfortunately, my script is still taking black screenshots.</p>