Showing posts with label Selenium. Show all posts
Showing posts with label Selenium. Show all posts

Sunday, July 18, 2010

Make a browser screenshot in Ruby with Selenium


First you need to have Selenium RC installed and launched. It's pretty simple. Download it, go to the selenium-server-1.0 and enter in command line
java -jar selenium-server.jar
Your Selenium server is started on the 4444 port, ready to be used ! You also need the selenium-client installed.
sudo gem install selenium-client
Your hard drive is now a bit less empty. We can start having fun with code !
require 'rubygems'
require 'selenium'

# We load Selenium
@selenium = Selenium::SeleniumDriver.new("localhost", 4444, "*firefox", "http://42.dmathieu.com/", 10000);
@selenium.start

# We go to the main page and take the screenshot
@selenium.open "/"
@selenium.capture_entire_page_screenshot(File.expand_path(File.dirname(__FILE__)) + 'screenshot.png', '');

# We unload Selenium
@selenium.stop
We load the required libraries. Not complicated. We only need Selenium.

require 'rubygems'
require 'selenium'
Then we load Selenium, indicating the URL we wish to visit and the browser with which we want to visit it.
@selenium = Selenium::SeleniumDriver.new("localhost", 4444, "*firefox", "http://42.dmathieu.com/", 10000);
@selenium.start
We load the page, take the screenshot and save the created image.
@selenium.open "/"
@selenium.capture_entire_page_screenshot(File.expand_path(File.dirname(__FILE__)) + 'screenshot.png', '');
And we don't forget to free the memory.
@selenium.stop
And then the magic happens. Our beautiful screenshot (of the entire page, not only the screen) is then generated.

http://dmathieu.com/en/ruby/make-a-browser-screenshot-in-ruby-with-selenium

Wednesday, July 14, 2010

Making urls look memorable

Bluga.net WebThumb provides a white-label web service API for generating web thumbnails and full size snapshots of websites.
WebThumb offers more features and quicker response times then any other service.
  • Real-time thumbnails
  • Flash 10 Support
  • PDF Support
  • Quick response times
  • REST API
  • API clients for PHPRubyPython
  • Cache the thumbnails on your server or Webthumbs
  • Browser windows from 75x75 to 1280x2048
http://snippets.dzone.com/posts/show/3621
http://www.paulhammond.org/webkit2png/
http://stackoverflow.com/questions/726660/how-do-i-make-beautiful-screenshots-of-web-pages-using-ruby-and-a-unix-server
rbwebkitgtkhttp://github.com/danlucraft/rbwebkitgtk/tree/master

Moz snap shooterhttp://www.lilik.it/~mirko/Ruby-GNOME2/moz-snapshooter.rb
http://www.hackdiary.com/2004/06/13/taking-automated-webpage-screenshots-with-embedded-mozilla/

Selenium RC has a Ruby interface and can grab a screenshot using: http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/ruby/classes/Selenium/Client/GeneratedDriver.html#M000220

PageGlimpse is a service providing developers with programatic access to thumbnails of any web page. The thumbnails can be virtually used in any kind of applications that require the display of website screenshots: web sites, windows/linux/mac applications, iPhone/mobile utilities, browser plugins, etc. 
Including web site thumbnails in your application will dramatically improve the user experience. The service is easy to use, fast and reliable, no restriction on thumbnail sizes or number of hits. Click here to see how it works.
http://www.pageglimpse.com/