title: Get fully rendered HTML using Selenium webdriver and Python
body: <p>I'm trying to build a web scraper in Python using Selenium webdriver but I'm unable to access the information I need when I retrieve the website source code from webdriver.</p>
  
  <p>I think the issue is that content is added to the page via JavaScript once the page has initially been downloaded from the server. When I run <code>browser.page_source</code> I get the source code of the page before this content was added. I want to know whether it is possible to get the source code of the page after the content loaded with JavaScript has been added (in other words what I see when I look at the page using Inspect Element).</p>
  
  <p>Here is the basic Python script I'm using:</p>
  
  <pre><code>from selenium import webdriver
  
  browser = webdriver.Chrome()
  browser.get("https://www.opportunities.auckland.ac.nz")
  print(browser.page_source)
  </code></pre>
  
  <p>When I run the above script I get the source code of the page I see when looking at the page source in the browser (i.e. without the additional content visible when the code is viewed with inspect element).</p>
  
  <p><strong>Things I've tried</strong></p>
  
  <ul>
  <li>Adding <code>time.sleep(10)</code> in various places in case the page had not fully loaded when I was accessing the source.</li>
  <li>Using <code>get_attribute("innerHTML")</code> on the body.</li>
  <li>Using <code>execute_script()</code> to make the JS run.</li>
  <li>Using <code>execute_script()</code> to make the JS scripts run one by one.</li>
  </ul>
  
  <p>It would be great if someone could tell be firstly whether this is possible and if it is point me in the right direction. Thanks.</p>
  
  <p><strong>Update 1</strong></p>
  
  <p>I get the following output when trying Piotrek's solution:</p>
  
  <pre><code>Warning (from warnings module):
    File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/phantomjs/webdriver.py", line 49
  warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '
  UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
  &lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Unfortunately this seems not to work.</p>