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
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 and Firefox drv = Driver.create(:android) # uses Appium (browser or device) drv = Driver.create(:phantomjs) # use Selenium and PhantomJS drv.navigate.to "..." # delegates to Selenium or Appium
See the documentation on configuration features for details on configuration.
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
Additional Drivers
- unobtainium-nokogiri is a nokogiri-based driver for entirely browserless access to XML and HTML files and pages.
- unobtainium-faraday is a faraday-based driver for dealing with RESTish APIs.
- unobtainium-kramdown is an open-uri-based driver for dealing with Markdown structured text.
Driver Modules
-
unobtainium-multifind
is a module providing a
#multifindfunction for searching for multiple elements at the same time. -
unobtainium-multiwait
based on
multifind, simplifies waiting for an element to appear.
Integrations
- unobtainium-cucumber integrates with cucumber, specifically providing some convenient functionality such as automatic screenshot taking on failures.
Credits
This gem is inspired by LapisLazuli, but vastly less complex, and aims to stay so.