add timeout argument, part of MKWS-276
[mkws-moved-to-github.git] / test / phantom / screenshot.js
1 var page = require('webpage').create(),
2     system = require('system');
3
4 var url = system.args[1] || 'http://www.indexdata.com/';
5 var file_png = system.args[2] || 'indexdata.png';
6 var timeout = system.args[5] ? system.args[5] : 0.2;
7
8 if (system.args.length === 1) {
9     console.log('Usage: screenshot.js <some URL> <file.png>');
10     phantom.exit();
11 }
12
13 // page.zoomFactor = 1.0;
14 page.viewportSize = {
15     width: system.args[3] ? system.args[3] : 1200,
16     height: system.args[4] ? system.args[4] : 1000
17 };
18
19 page.clipRect = {
20     width: page.viewportSize.width,
21     height: page.viewportSize.height
22 };
23
24 page.open(url, function () {
25     // small delay
26     setTimeout(function () {
27         var ret = page.render(file_png);
28         phantom.exit();
29     }, timeout * 1000);
30 });