title: How to run webpage code with PhantomJS via GhostDriver (selenium)
body: <p>I looking for ability render pdf with <code>PhantomJS</code> via <code>GhostDriver</code>, not just render pdf. When I use next code, then page normally loaded:</p>
  
  <pre><code>from selenium import webdriver
  
  driver = webdriver.PhantomJS('./node_modules/phantomjs/bin/phantomjs')
  driver.set_window_size(1024, 768)
  driver.get('http://stackoverflow.com')
  </code></pre>
  
  <p>When I use next script via command line <a href="https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js" rel="nofollow">https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js</a> then pdf generated perfectly.</p>
  
  <p>Now I want execute script like <code>rasterize.js</code> (<code>page.render('file.pdf')</code>) but via <code>webdriver</code>. <code>webdriver</code> has <code>execute_script</code> method but it look like <code>PhantomJS</code> code evaluation and do not have access to <code>webpage</code> instance context. Also <code>webdriver</code> has <code>get_screenshot_as_base64</code> method, but it return only png.</p>
  
  <p>I use latest versions of <code>selenium</code>, <code>phantomjs</code>, <code>nodejs</code>.</p>
  
  <p>So my question how I can get access to <code>PhantomJS</code> webpage instance via <code>GhostDriver</code> and evaluate <code>render</code> method?</p>