I'm using PhantomJS as a Selenium webdriver, and I have an in-memory string of a webpage.
How can I load the string into PhantomJS akin to what would happen if I did driver.get()?
I've looked all over but can't find anything like this short of writing a file to disk and GETing that. But that feels a little crazy.
Did you mean something like this by Data URI scheme?
demo_page = '''
data:text/html,
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test "How to load up PhantomJS with a Python string"</title>
</head>
<body>
<a href="http://stackoverflow.com/q/24834838/1177636">How to load up PhantomJS with a Python string</a>
</body>
</html>
'''
driver = webdriver.PhantomJS()
driver.get(demo_page)
driver.save_screenshot('screenshot.png')
driver.quit()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With