使用phantomjs.rb gem时,我无法从我的应用程序中获取屏幕截图。我目前正在尝试本地网址。如果我得到那些工作,我将稍后使用url_for。
在我的控制器中:
Phantomjs.run('./public/javascripts/testScreenCapture.js', 'http://localhost:3000')
我的testScreenCapture.js:
var page = require('webpage').create();
var args = require('system').args;
var url = args[1];
page.open(url, function () {
window.setTimeout(function () {
page.render('./public/appPage.png');
phantom.exit();
}, 3000);
});
传递“http://www.google.com”作为url参数工作正常,就是当我从本地服务器传递任何东西时,当rails服务器挂起并且我也假设了phantomjs脚本,因为我没有得到我的公共文件夹中的屏幕截图。
更奇怪的是从命令行运行它:
phantomjs public/javascripts/testScreenCapture.js http://localhost:3000
这很棒!所以我假设我的控制器与服务器冲突有问题。有什么想法吗?