From bd63dc334595b8de592d25bb673cc441b0679162 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Thu, 30 Jan 2014 18:40:41 +0000 Subject: [PATCH] support command line args, e.g.: phantomjs screenshot.js http://www.indexdata.com indexdata.png --- test/spec-dev/screenshot.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/spec-dev/screenshot.js b/test/spec-dev/screenshot.js index 038f12d..72dbe5e 100644 --- a/test/spec-dev/screenshot.js +++ b/test/spec-dev/screenshot.js @@ -1,15 +1,20 @@ -// run: phantomjs /path/to/this/file -var url = 'http://www.indexdata.com/'; -var file_png = "indexdata.png"; +var page = require('webpage').create(), + system = require('system'); -var page = require('webpage').create(); +var url = system.args[1] || 'http://www.indexdata.com/'; +var file_png = system.args[2] || 'indexdata.png'; + +if (system.args.length === 1) { + console.log('Usage: screenshot.js '); + phantom.exit(); +} // page.paperSize = { format: 'A4', orientation: "landscape" }; +// page.zoomFactor = 1.0; page.viewportSize = { - width: 960, - height: 800 + width: 1200, + height: 1000 }; -page.zoomFactor = 1.0; page.open(url, function () { // small delay -- 1.7.10.4