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.
Cucumber, Selenium and Watir
Below I will describe in a short summary the main functions of these solutions.
This is what makes Ruby code usable for Continous Integration. It helps you turn code into readable text. Most commonly used for Gherkin style output.
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.
Gijs Paulides – spriteCloud – test automation engineer