I am trying to build a utility function to output beautiful soup code to a browser I have the following code: def bs4_to_browser(data): from selenium import webdriver driver = webdriver.Firefox(path="F:\FirefoxPortable\Firefox.exe") driver.get("about:blank") data = '<h1>test</h1>' # supposed to come from BeautifulSoup driver.execute_script('document.body.innerHTML = "{html}";'.format(html=data)) r