TestUtils

Collection of useful test related modules.

Installation

Add this line to your application's Gemfile:

  gem 'test_utils'

And then execute:

$ bundle

Or install it yourself as:

$ gem install test_utils

Usage

Start up a browser locally

Set the environment variable "BROWSER" to "Chrome", "Firefox" or "Mobile". The drivers are already included in the (resources) directory.

$ BROWSER=Chrome

require 'test_utils/browser_tests/browser_setup'
include BrowserSetup

start_browser
@browser.goto 'https://github.com/ef-ice/test_utils'
raise 'not found!' unless @browser.title.include?('Readme')
close_browser

Note: Using "Mobile" will start a browser in mobile size (this uses the webdriver-user-agent gem)

Start up a browser in Browser stack

Browserstack requires to set four capabilities to start up a browser (os, osVersion, browser, browserVersion). This is too cumbersome, so instead with this gem you can set a single environment variable called "BS" that combines all of these together and sets them up on their corresponding capabilities when you call "start_browser".

The format for the "BS" environment variable is "osName_osVersion_browserName_browserVersion" in desktop, and "device_version" in mobile.

Running tests in desktop:

  1. osName: win (windows), mac.

  2. osVersion: See options here.

  3. browserName: ie, chrome, firefox, etc.

  4. browserVersion: blank for latest, otherwise any option from here.

Valid values for mobile:

  1. device: iphone, android.

  2. deviceVersion: 6s, nexus5, etc. (see options here)

Examples

  1. Set your "BS" env var:

$ BS="win_7_ie_11"

$ BS="win_7_chrome"

$ BS="iphone_6s"

  1. Set your credentails:

$ BS_USER_NAME="your_username"

$ BS_AUTH_KEY="your_key"

Note: Not including the browser version will get the latest available version of the browser. For the full list of browsers available in Browserstack Automate please go here

Start up a browser in Headless mode

Setting the environment variable "HEADLESS" to "true", will start a headless display (this uses the headless gem)

$ HEADLESS=TRUE

Note: Does not work in Mac. Works in Linux.

Other watir utils

Have a look at other useful methods in the web_helper module.