What does Lapis Lazuli add to Watir, Selenium and Cucumber?
Hello, I am Gijs, one of the developers of Lapis Lazuli. I often get the question why we use Lapis Lazuli in addition to Watir. In this post I will explain each of the systems unique abilities and then I will list the advantages of using Lapis Lazuli.
Update: We’ve released a new version of Lapis Lazuli, 3.0.0, check it out at RubyGems.org
Cucumber, Selenium and Watir
Below I will describe in a short summary the main functions of these solutions.
The core purpose of Selenium is to convert browser functionality to coded functions, so a developer can communicate with a browser. Every browser has their own so called ‘driver’ and each driver has its own functions and methods to communicate with it. Selenium Webdriver unifies these differences and translates it to your favourite programming language. In our case: Ruby.
Watir makes the usage of Selenium much simpler. Where Selenium is still quite complicated and “codey” to use, Watir jumps in and simplifies it for you. For example
browser.div selects the first div element on a page and
browser.divs selects all div elements on a page. Thanks to Watir, test automation becomes easier and more readable.
With the combination of the 3 solutions, you can build a fully functional test automation suite, which can run your code automatically and gets your results in an orderly fashion. This is what Lapis Lazuli does. When installing Lapis Lazuli, you can use a command
lapis_lazuli create [project-name] and it will generate a basic project in which you can instantly start automation.
In the past, we combined the 3 systems manually here at spriteCloud, but we noticed that often the test automation engineer was dropping the ball on writing good code. We started seeing too many false-positives or false-negatives in our code. Mainly false-positives were a problem, because it doesn’t show issues.
Enforcing best practises
We’re still completely dependent on Watir’s way of interacting with elements, like clicking, hovering or setting values of input fields. But we have re-written a major part of how to select elements. Lapis Lazuli enforces the best practises in the following ways:
- Automatically throw an informative error when an element is not found, with an option to disable this.
- Discourage using regular expressions to find an element by providing a better alternative.
- Finding an element is just as easy as waiting for an element, preventing timeout errors.
Finally, in combination with Cucumber, screenshots are automatically taken when a scenario fails. The screenshot is given a unique name that consists of a timestamp and the step in which it failed. This enables the possibility to link failed steps to the screenshot and display it.
Selenium, Watir and Cucumber are legendary solutions that bring great possibilities for TA-engineers in the Ruby world. Lapis Lazuli simply makes use of this to combine it into 1 well oiled TA-package.
We believe that Cucumber and Behaviour Driven Development represent very robust solutions for automating tests which is why we’ve combined out knowledge and experience into a Cucumber and Gherkin Guide for you to use. Enjoy!
Gijs Paulides – spriteCloud – test automation engineer
In the past, I’ve worked on many projects where they either used Gherkin to describe functionality or to be used for test automation. However, my
Build great software faster! CI/CD is hot and is still gaining interest. Test Automation is obviously essential within any Continuous Integration setup in order to
Aside from the tools explained in this post, we have recently launched a test results dashboard designed to help you maintain an overview of all