unobtainium
Obtain the unobtainable: test code covering multiple platforms
Unobtainium wraps Selenium and Appium in a simple driver abstraction so that test code can more easily cover:
- Desktop browsers
- Mobile browsers
- Mobile apps
The gem also wraps PhantomJS for headless testing.
Some additional useful functionality for the maintenance of test suites is also added.
Usage
You can use unobtainium on its own, or use it as part of a cucumber test suite.
Unobtainium's functionality is in standalone classes, but it's all combined in
the Unobtainium::World module.
The
PathedHashclass extendsHashby allowing paths to nested values, e.g.:h = PathedHash.new { "foo" => { "bar" => 42 }} h["foo.bar"] == 42 # trueThe
Configclass is aPathedHash, but also reads JSON or YAML files to initialize itself with values. See the documentation on configuration features for details.The
Runtimeclass is a singleton and aHash-like container (but simpler), that destroys all of its contents at the end of a script, calling custom destructors if required. That allows for clean teardown and avoids everything having to implement the Singleton pattern itself.The
Driverclass, of course, wraps either of Appium or Selenium drivers:drv = Driver.create(:firefox) # uses Selenium drv = Driver.create(:android) # uses Appium drv.navigate.to "..." # delegates to Selenium or Appium
World
The World module combines all of the above by providing a simple entry point for everything:
World.config_filecan be set to the path of a config file to be loaded, defaulting toconfig/config.yml.World#configis aConfiginstance containing the above file's contents.World#driverreturns a Driver, initialized to the settings contained in the configuration file.
For a simple usage example of the World module, see the cuke subdirectory (used with cucumber).
Configuration File
The configuration file knows two configuration variables:
driveris expected to be a string, specifying the driver to use as if it was passed toDriver.create(see above), e.g. "android", "chrome", etc.drivers(note the trailing s) is a Hash. Under each key you can nest an options hash you might otherwise pass toDriver.createas the second parameter.
See the documentation on configuration features for details.
Development
Credits
This gem is inspired by LapisLazuli, but vastly less complex, and aims to stay so.
