generate screenshots of Koha widget in production / marketing, MKWS-276
[mkws-moved-to-github.git] / test / phantom / screenshot.js
index 150f7e4..40f9937 100644 (file)
@@ -3,6 +3,7 @@ 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 <some URL> <file.png>');
@@ -11,15 +12,19 @@ if (system.args.length === 1) {
 
 // page.zoomFactor = 1.0;
 page.viewportSize = {
-    width: 1200,
-    height: 1000
+    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();
-    }, 500);
+    }, timeout * 1000);
 });
-