Render series of responses in selenium webdriver
<p>I want to collect a series of responses when navigating a website, and afterwards "recreate" the process <strong>using the responses</strong>.</p>

<p>From an <a href="http://stackoverflow.com/questions/36785588/render-http-responsehtml-content-in-selenium-webdriverbrowser">other thread</a> I found this solution to render HTML:</p>

<pre><code>content = requests.get("http://stackoverflow.com/").content

driver = webdriver.Chrome()
driver.get("data:text/html;charset=utf-8," + content)
</code></pre>

<p>Unfortunately, when I try this (using Firefox instead of Chrome), the content is simply put into the browser address bar.</p>

<p>How can I render a series of responses, including for example XHR-responses with selenium webdriver?</p>

<p>You have to account for certain browser-specific things, like the fact that <a href="http://stackoverflow.com/a/9239272/771848"><code>#</code> and <code>%</code> have to be escaped if you use Firefox</a> - from what I understand, you can simply pass the content through <code>quote()</code>:</p>

<pre><code>try:
    from urllib import quote  
except ImportError: 
    from urllib.parse import quote # if Python 3

driver.get("data:text/html;charset=utf-8," + quote(content))
</code></pre>

<p>No need to do that if you use Chrome.</p>

javascript python selenium selenium-webdriver