0
我試圖在Rails 4應用程序中截取頁面截圖。我已經嘗試了幾種方法,但最乾淨的似乎是通過使用水豚與poltergeist。在Rails中截取屏幕截圖
在我的Gemfile我有以下幾點:
gem 'capybara'
gem 'capybara-screenshot'
gem 'poltergeist'
和我的rake任務是這樣的:
desc "Take a screenshot of top three articles"
task :screenshots => :environment do
require 'capybara'
require 'capybara/poltergeist'
include Capybara::DSL
Capybara.default_driver = :poltergeist
Capybara.run_server = false
articles = Article.order('score DESC').limit(3)
articles.each do |article|
visit(article.url)
screenshot_and_save_page
end
end
然而,這是給我這樣的錯誤,例如:
Unsafe JavaScript attempt to access frame with URL <someurl> from frame with URL http://static.ak.facebook.com/connect/xd_arbiter.php?version=40#channel=fcf48aa3c&origin=http%3A%2F%2Fwww.independent.co.uk. Domains, protocols and ports must match.
任何線索如何解決這個問題?