Skip to content

Instantly share code, notes, and snippets.

@bgnori
Created June 5, 2013 23:59
Show Gist options
  • Save bgnori/5718307 to your computer and use it in GitHub Desktop.
Save bgnori/5718307 to your computer and use it in GitHub Desktop.
PyYAML==3.10
selenium==2.33.0
<html>
<head>
<title>Runner</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js">
</script>
<script>
</script>
</head>
<body><div id="output"></div></body>
</html>
import sys
from StringIO import StringIO
buf = StringIO()
from selenium import webdriver, selenium
driver = webdriver.PhantomJS('/usr/local/bin/phantomjs')
driver.get("file:///home/nori/Desktop/work/kn/js/hoge.html")
driver.execute_script(r'''$(document).ready(function(){
$("#output").replaceWith("<div>webdriver!</div>")
});''')
print driver.current_url
print driver.title
print driver.page_source
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment