X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Fphantom%2Fscreenshot.js;h=22f044ff8bb5c9e64b1343298c35456639253607;hb=8c6a4e3f2f858d44345de4564bcb14ba1b44fbd2;hp=a91addfd1463068149731b72db1b8a0c0ecc85f3;hpb=555e9f7c667615844f188fe538b2fd52138ccd3b;p=mkws-moved-to-github.git diff --git a/test/phantom/screenshot.js b/test/phantom/screenshot.js index a91addf..22f044f 100644 --- a/test/phantom/screenshot.js +++ b/test/phantom/screenshot.js @@ -3,22 +3,42 @@ var page = require('webpage').create(), var url = system.args[1] || 'http://www.indexdata.com/'; var file_png = system.args[2] || 'indexdata.png'; +var timeout = system.args[5] ? system.args[5] : 0.2; -if (system.args.length === 1) { - console.log('Usage: screenshot.js '); +function usage(message) { + if (message) { + console.log(message + "\n"); + } + console.log('Usage: screenshot.js '); phantom.exit(); } +if (system.args.length === 1) { + usage(); +} + +if (!file_png.match(/\.png$/)) { + usage("File name has no .png extension: '" + file_png + "'"); +} + + // page.zoomFactor = 1.0; page.viewportSize = { width: system.args[3] ? system.args[3] : 1200, height: system.args[4] ? system.args[4] : 1000 }; +page.clipRect = { + width: page.viewportSize.width, + height: page.viewportSize.height +}; + page.open(url, function () { // small delay setTimeout(function () { - page.render(file_png); + var ret = page.render(file_png); phantom.exit(); - }, 200); + }, timeout * 1000); }); + +// EOF