Ruby is a very popular language among web developers and companies, Newis developer prefer these languages among other languages. Ruby on Rails aka Rails, is Web development framework made further popularity for Ruby.

In this tutorial we are using watir gem to take website screenshots. We use this gem to  take screenshots of a website before and after update. Many thing can be broken in WordPress update, so we decide to build an application to take screenshots, so we can check it’s UI  work well or not. We choose Ruby and Ruby on Rails framework because of popular gems and well documented document.

Install dependencies

  1. Install required Debian/Ubuntu libraries
  2. Yes, You must have Google chrome, Use your software manager or download chrome from Google.
  3. Install xvfb to run chrome headlessly
  4.  Install unzip package sudo apt-get install unzip
  5. Goto Google chrome driver download website and find latest version, Download Website .
  6. Run following command to install Google webdriver.

    Please change X.XX with latest version
  7. Install selenium , Please check this link to get latest Selenium.

    Please change X.X.X and X.XX
  8.  Export path so it will get it terminal.
  9. Do the same for selenium
  10. Install Phantomjs and other required libraries ( It is not required for watir, but we can use phantomJS instead of chrome browser )
  11. Install required gems
  12. Ruby script to take screenshots

Updates: Use with headless gem

Screensize  calculate using Javascript via execute script

Save Images using Carrierwavegem

 

Mainly we need selenium drivers, chrome/phantomjs or firefox webdriver, Linux and Ruby libraries to get headless environment.

Images will saved on the folder, where you open terminal.