Skip to content

Instantly share code, notes, and snippets.

@kedorlaomer
Created July 6, 2015 12:00
Show Gist options
  • Save kedorlaomer/531cfeaf11d070f6ea1a to your computer and use it in GitHub Desktop.
Save kedorlaomer/531cfeaf11d070f6ea1a to your computer and use it in GitHub Desktop.
How sendEvent in slimerjs doesn't work
var page = require('webpage').create();
page.open("http://slimerjs.org", function(status) {
if (status == 'success') {
page.render('out.jpg', {quality: '100'});
}
})
window.setTimeout(function() {
var pair = page.evaluate(function(){
var button = document.getElementById("download");
var x = button.getBoundingClientRect().x;
var y = button.getBoundingClientRect().y;
return [x, y];
});
var x = pair[0]; var y = pair[1];
page.sendEvent('click', x+2, y+2, 'left');
// second screenshot (nothing has changed!)
window.setTimeout(function() {
page.render('out2.jpg', {quality: '100'});
}, 5000);
} , 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment