Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
//http://slimerjs.org/
var page = require('webpage').create();
page.viewportSize = { width:1280, height:800 };
page.open('http://localhost/phpmetrics.html')
.then(function(){
window.setTimeout(function() {
page.clipRect = { top: 212, left: 55, width: 300, height: 280 };
page.render('build/logs/phpmetrics-maintainability.png');
page.clipRect = { top: 210, left: 400, width: 300, height: 275 };
page.render('build/logs/phpmetrics-custom.png');
page.clipRect = { top: 255, left: 750, width: 300, height: 275 };
page.render('build/logs/phpmetrics-abstractness.png');
page.evaluate(function () {
return document.querySelector("#link-score a").click();
});
window.setTimeout(function() {
page.clipRect = {top: 170, left: 65, width: 560, height: 560};
page.render('build/logs/phpmetrics-evaluation.png');
page.clipRect = {top: 315, left: 645, width: 560, height: 200};
page.render('build/logs/phpmetrics-evaluation-report.png');
page.close();
phantom.exit();
},
3000);
},
3000);
})

phantom.exit(); won't work with phantomjs: how about use CasperJs instead ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment