Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 16-Sep-16 7:20am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900