Ruby gem for interacting with the browserstack api
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.ruby-gemset
.ruby-version
Gemfile
LICENSE.txt
README.md
Rakefile
browserstack.gemspec

README.md

Browserstack

A ruby gem for working with BrowserStack through its API.(V2 API only)

Installation

Add this line to your application's Gemfile:

gem 'browserstack'

And then execute:

$ bundle

Or install it yourself as:

$ gem install browserstack

Example of Use

First, you're probably gonna want to require it:

require 'browserstack'

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.
client = Browserstack::Client.new(username: "foo", password: "foobar")

API

Getting available browsers

Fetches all available browsers.

client.get_browsers #returns a hash

or for a specific OS

client.get_browsers("mac")

Getting list of supported OS

client.get_supported_os_list 

Creating a worker

A worker is simply a new browser instance.

enc_url = URI.escape("http://example.com/?a=\111\\115")
settings = {os: "win", browser: "ie", version: "7.0", url: enc_url}
worker_id = client.create_worker(settings)

A worker id is returned after worker gets created.

  • settings: A hash of settings for the worker
    • os: Which OS to use for the new worker.
    • browser/device: Which browser/device to use in the new worker. Which property to use depends on the OS.
    • version: Which version of the specified browser to use.
    • url : Which URL to navigate to upon creation.
    • timeout (optional): defaults to 300 seconds. Use 0 for "forever" (BrowserStack will kill the worker after 1,800 seconds).

Terminating a worker

Use this method to terminate an active worker. A hash with indicating how long the worker was alive is returned.

data = client.terminate_worker(worker_id)

Getting worker status

Determines whether the worker is in queue, running or terminated.

worker = client.get_worker_status(worker_id)
  • worker: A hash representing the current status of the worker and worker properties.
    • returns an empty hash if worker is terminated.

Getting all workers of a client

workers = client.get_workers

Returns an array of all workers with all their properties

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