Created
November 2, 2011 23:03
-
-
Save jonleighton/1335232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
page = require('webpage').create() | |
page.content = | |
"<html> | |
<body> | |
<div id='foo' style='width: 100px; height: 400px;'></div> | |
</body> | |
</html>" | |
page.onConsoleMessage = (message) -> | |
console.log(message) | |
page.evaluate -> | |
document.onclick = (e) -> | |
console.log("#{e.pageX},#{e.pageY}") | |
page.viewportSize = { width: 100, height: 100 } | |
page.scrollPosition = { left: 0, top: 200 } | |
page.sendEvent('click', 0, 0) | |
# => Page receives click at 0,200 | |
page.evaluate -> | |
document.getElementById('foo').style.height = '250px' | |
# => The current viewport position now extends 50px below the bottom of the page | |
page.sendEvent('click', 0, 0) | |
# => Page receives click at 0,166 | |
phantom.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment