I have button/link that takes a screenshot when clicked. How can I automate this to click the link on all pages to take the screenshot by a script so I can have all screenshots available. Trying to avoid having to go to all pages to click that button manually. Possibly through a rake but I've never created one before.
VIEW
<%= link_to 'Take Screenshot', capture_image_account_site_path(@account, @site), method: :post, data: { disable_with: 'Processing...', id:'screenshot' } %>
CONTROLLER
def capture_image
@site = Site.find(params[:id])
@ws = Webshot::Screenshot.instance if @site.primary?
@url = @site.website
@ws_image = @ws.capture strip_url(@site.website), "#{Rails.root}/public/images/screenshots/#{@site.id}.png", width:300, height:180, timeout:3
redirect_to(account_site_url(@account, @site, view: 'active'))
end
Thanks in advance.
What I have tried:
namespace :screenshot do
desc 'Take screenshot for all sites'
task take_screenshot: :environment do
Rails.application.routes.routes.each do |route|
filter out routes?
code for screenshot?
end
end