Coder Social home page Coder Social logo

trott / ruby-screenshots Goto Github PK

View Code? Open in Web Editor NEW

This project forked from browserstack/ruby-screenshots

0.0 3.0 0.0 76 KB

Ruby Wrapper for BrowserStack Screenshots API

Home Page: http://www.browserstack.com/screenshots

License: MIT License

ruby-screenshots's Introduction

BrowserStack Screenshots

A ruby gem for BrowserStack's Screenshot API.

Installation

Add this line to your application's Gemfile:

gem 'browserstack-screenshot'

And then execute:

bundle

Or install it yourself as:

gem install browserstack-screenshot

Example of Use

First, you need to require the screenshot gem:

require 'screenshot'

Creating Client

Creates a new client instance.

  • settings: A hash of settings that apply to all requests for the new client.
    • :username: The username for the BrowserStack account.
    • :password: The password for the BrowserStack account.
settings = {:username => "foo", :password => "foobar"}
client = Screenshot::Client.new(settings)

###API

####Getting available os and browsers Fetches all available browsers. API info

client.get_os_and_browsers 	#returns a hash

####Generating Screenshots Frame the config object according to the format given. Format info

Eg settings object:

params = {
	:url => "www.google.com",
	:callback_url => "http://example.com/pingback_url",
	:win_res => "1024x768",		#Options : "1024x768", "1280x1024"
	:mac_res => "1920x1080", 	#Options : "1024x768", "1280x960", "1280x1024", "1600x1200", "1920x1080"
	:quality => "compressed",	#Options : "compressed", "original"
	:tunnel => false,
	:browsers => [
			{:os=>"Windows",:os_version=>"7",:browser=>"ie",:browser_version=>"8.0"},
			{:os=>"Windows",:os_version=>"XP",:browser=>"ie",:browser_version=>"7.0"}
	]
}

callback_url, win_res, mac_res, quality and tunnel being optional parameters.

#####For testing Local/Internal Server setup

  • First setup local tunnel using the command line method as mentioned here
  • Pass :tunnel => true in the params object

A request id is returned when a valid request is made.

request_id = client.generate_screenshots params

####Checking/Polling the status of the request Use this method to check if the requested screenshots are complete.

client.screenshots_done? request_id	#returns `true` or `false`

Or you can fetch the request state

client.screenshots_status request_id	#returns `queue` or `processing` or `done`

####Fetching the response of the requested screenshots

client.screenshots request_id

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

ruby-screenshots's People

Contributors

ahmed1490 avatar rahulnwn avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.