One crucial and often overlooked step in delivering highly available enterprise software to the end user is testing. Here at eOriginal, we have a team of Automation Engineers whose job is to develop and maintain eOriginal’s automated testing suite.
We utilize a technology called Watir WebDriver to test eOriginal’s web-based portals. Watir allows us to write code that takes over a web browser and steps through various workflows to ensure the software is functioning as designed.
How It Works
A very simple example for illustrative purposes: We begin a test that sends an email invitation to electronically sign a document, but a phone number field is required first to complete SMS authentication. After the test logs into an email account and clicks the invitation link within the email, the browser opens the eOriginal SmartSign® software and prompts the test to enter a phone number for SMS authentication. The test enters several invalid phone numbers into the phone number field, ensuring appropriate warning messages appear on the screen each time, before finally entering a valid phone number. Once the test enters a valid phone number, a test message is sent to a Google Voice number. The test logs into Google Voice to retrieve the one-time use PIN. The test then enters the PIN, which allows for entry into the eOriginal SmartSign software, where it can complete the signing process.
We have hundreds of these Watir scripts that test the wide range of functionality of our eOriginal® technology. Our developers are constantly making enhancements based upon the tests we run every night against the latest build of our software. This helps us ensure that the eOriginal software still works properly without having to manually perform the many actions carried out by the program. When we check our test results every morning, we sometimes find a test failure that is the result of a bug in the software. Being able to quickly identify a problem means the issue can be resolved quickly.
The Nuts and Bolts of Automated Testing Code
The Watir WebDriver website offers instructions to get you started, and below I will illustrate a few lines of code related to the phone-number test described above.
Watir tests are written using the Ruby programming language, which is known for its elegance and readability. Building tests with Watir is no different. First, you start by telling Watir what type of browser you wish to use:
require ‘watir-webdriver’browser = Watir::Browser.new :chrome
This is referred to as your browser object. With your browser object created, next you tell the browser where to navigate:
Then, you tell Watir to look for the part of the page you want to click on or type in. This part of the page is called an HTML element. Browsers have tools that help you identify the unique names of these elements, like Developer Tools in Chrome or Firebug in Firefox. Once you find the identifier of this element, you tell Watir what to do with it:
browser.text_field(:id, ‘formField_1_72_93’).set ‘567’
The line above says, “Find the text field box on the screen that has a unique ID of ‘formField_1_72_93’ and enter a value of ‘567’ into that box.”
Since “567” is not a valid phone number, we expect the software to prompt a warning message:
browser.span(:text, ‘Telephone Number Field must be a valid phone number’).present? == true
Above, Watir is looking for an HTML span that warns the user that the data entered is invalid. If the text is found on the screen, the result is true. If this text is not found, the result is false. We print this output to our monitoring system which automatically parses, summarizes, and posts the results to an internal web page that we consult each morning.
After entering a correct phone number, the Watir test then verifies that the warning text is not present (i.e., “…present? == false”).
Each check or verification a test does is called an assertion. Each test has an average of 10-15 assertions. The ability to automate our testing has proven to be imperative and it also helps to ensure that eOriginal’s software is of the highest quality possible.
The post above is a brief introduction to the way we implement automation testing at eOriginal to produce a solid end-product for our customers. Two future installments will go into greater detail on specific Watir topics. It’s pretty fun to write these tests and watch your web browser run on autopilot, and it’s a proud moment when a test you wrote squashes a software bug!