Logo: Selenium Web Automation
The web automation tool Selenium started out as a joke by developer Jason Huggins – who mocked a competitor, Mercury Interactive – as the element selenium can be used to cure mercury poisoning.

Eventually, Selenium evolved into an open-source toolset developed by Huggins for quality assurance and testing across many different browsers and platforms.


First, let’s look at the four different elements contained in Selenium:

1)Integrated Development Environment (IDE) is a Firefox-only plug-in used to create testing scripts through a record-and-playback feature. There are also a number of plug-ins for the IDE itself that can be added to extend its features. The IDE is very simple and easy to learn. However, because of its simplicity, it cannot be used to create complex testing scripts, with the other portions of Selenium having to be used instead.

Screenshot: Selenium IDESelenium IDE testing suite

2)Selenium Remote Control (RC) was the first web automation testing tool that let users create tests in a programming language of their choice. The languages that are currently supported by the main project as of version 3.0.1 are Java, C#, Ruby, Python, and JavaScript, although bindings for other languages also exist.

3)Selenium RC is also usually paired with a third component of Selenium called Selenium Grid. Grid was made to allow running tests in Selenium RC in parallel, which means to run tests in multiple different browsers and machines at the same time. This saves a great deal of time, as you would otherwise need to run the same test over and over again as you changed browsers and changed machines that you were testing. Grid does this by acting as a central hub which sends Selenium commands to all of the differents nodes that are connected to it, with these nodes then going on to run the tests.

4)Selenium WebDriver is another framework for creating testing scripts, but is better in many ways than both Selenium RC and Selenium IDE. It has a faster execution time. It is also more realistic than RC in the way that it interacts with the browser, and has no need for additional components such as RC does with Grid. While Selenium RC needs to rely on JavaScript to automate browsers, WebDriver can communicate directly with the browser to control it.

For a more in-depth look into exactly how the different parts of Selenium function and interact with one another, the official documentation can be found on the Selenium website.

Screenshot: Selenium WebdriverHere is an example of Selenium Webdriver code written in Java, testing out the login feature of GoFan, a digital ticketing platform that we developed here at Digital Scientists. This automatically opens up the browser, in this case Mozilla Firefox, and loads up the GoFan website before executing all the commands it needs to log in to the website. In this particular case, the actions were first created using the Selenium IDE and converted to a java file, which was then edited using Eclipse to run using Selenium Webdriver commands instead. This allows the code to be easily changed to work with other browsers, such as Google Chrome, whereas the original version created in the IDE could only run in Firefox.

How We Use Selenium at Digital Scientists
At Digital Scientists, we use Selenium to aid in quality assurance and creating tests for projects such as the GoFan digital ticketing platform developed for use in high schools, as well as eProve, which is a modular diagnostic platform that can conduct observations in classrooms in order to enhance student engagement. To help define what needs to be done in a test case, Digital Scientists uses the concept of a “Story” to easily determine what aspects needs to be part of a test case. Essentially, a story contains the requirements of a certain test case and the criteria by which it needs to to be accomplished. The structure is generally laid out like this:

Title (one line describing the story)

Narrative:
As a [role] I want [feature] So that [benefit]

Acceptance Criteria: (presented as Scenarios)

Scenario 1: Title
Given [context] And [some more context]…
When [event] Then [outcome] And [another outcome]…

Scenario 2: …

An example of this used by Digital Scientists is in this image, which outlines the given conditions and expected behavior when running a test that logs in to eProve.

Screenshot: User story
You can visit Dan North’s guidelines for What’s in a Story for a more advanced look at the uses and benefits of a story as well as for the source of the structure given above.


How Alternatives Stack Up
Some alternatives to Selenium are Sahi and Watir. Watir is a web automation tool that works solely with Ruby, meaning that if you don’t know how to create scripts in Ruby you would be forced to learn it in order to use Watir.

The benefits of Watir are that it is a Ruby library, has a ‘Simple’ class that makes it easy to use for users who are not as technically-inclined, and has a very rich API. Watir also incorporates Watij and Watin, which are versions that use Java and .NET, respectively. However, the documentation for either version is lacking.

Sahi is similar to Selenium, providing multi-browser support as well as its own IDE that allows for recording tests and playing them back. However, the interface is non-intuitive. Additionally, it is the least developed tool of the three discussed here.

Benefits: Flexibility, Multi-language and Integration Capabilities
One major drawback that isn’t found in some of the other automation tools such as Watir is that Selenium does not wait for the page to load automatically. As a result, timing problems are common with Selenium as it attempts to follow a command before an item becomes available.

Despite these minor disadvantages, Selenium is the most popular choice for automation testing. We use it at Digital Scientists because of its flexibility and support for many different languages. It can also integrate with other useful tools such as BrowserStack and Protractor to make the testing experience better overall.

Izaan Kamal is a Digital Scientists intern from Alpharetta High School.