Lapis Lazuli:Usage

From Test Automation Wiki
Revision as of 13:29, 20 October 2016 by Markb (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

LapisLazuli provides extra functionality for your cucumber test suites. The library is structured in the following way:

  1. It provides extensions to the cucumber World object - the object that provides all the methods you can use in your step definitions. These extensions are implemented in WorldModule modules.
  2. It provides an enhanced version of the watir browser. Extensions to the browser are implemented in BrowserModule modules.


The LapisLazuli module itself includes all WorldModule functionality provided by the library. To use all the extensions at once, simply do the following:

# features/support/env.rb
require 'lapis_lazuli'

However, you don't need to drink from the firehose, and can instead pick and choose which extensions to use:

# features/support/env.rb
require 'lapis_lazuli/world/annotate'

There's one caveat: the most useful `WorldModule` is the `Browser` module, which handles creating and destroying an enhanced watir browser instance for you. To do so, this module includes quite a few other WorldModules. In fact, it's not the only module that does so. In many cases, then, simply including all of LapisLazuli is going to be the easiest.

Lapis Lazuli library consist of a module called LapisLazuli and its main class LapisLazuli. The class is a singleton, which means that any reference to LL will be the same instance with links to the same browser window.

In order to get the full power of LapisLazuli, you will most likely want to automatically add the hooks from the WorldModule:Hooks module. You can do this by also requiring the cucumber file:

# features/support/env.rb
require 'lapis_lazuli'
require 'lapis_lazuli/cucumber'

Interactive Usage

Interactive usage of LapisLazuli in irb is just as easily possible:

require 'lapis_lazuli'
include LapisLazuli
browser.goto ""

Which results in:

$ irb
irb(main):001:0> require 'lapis_lazuli'
=> true
irb(main):002:0> include LapisLazuli
=> Object
irb(main):003:0> browser.goto ""
=> ""

New Projects

In many cases you will be starting out with a new test automation suite. LapisLazuli helps you with that, by creating one from a template included in the library:

$ lapis_lazuli create <projectpath>

A skeleton test suite with LapisLazuli loaded will be created at the given project path. You can use create - or it's alias update - to keep the test suite up-to-date when you upgrade to a new version of LapisLazuli, too.

Documentation Structure

Because of the structure of the library, the wiki documentation is structured by WorldModule and BrowserModule, too.