Skip to content
Mat Walker edited this page Apr 18, 2018 · 1 revision

Controlium is primarily an overlay that extends Selenium. Selenium enables test automation code to interact with UI's. Usually the UI is browser-based but sometimes can be non-Browser, such as when Appium is used as the Selenium server; at its core, Selenium is just the jason-based protocol of communication between a Selenium client and a Server.

The interaction with the UI is HTML element based. Code identifies an element within the HTML DOM and then interacts with that element to obtain information or send events. An element is identified using a range of technologies, such as XPath or CSS. When using XPath (and possibly others), an Element may be identified absolutely (IE. The identification logic is applied to the root node of the DOM) or relatively (IE. Identification logic is applied from an already identified Element).

Selenium provides two methods for identifying an Element; FindElement, which applies the identification logic and returns the first matching Element. And FindElements, which returns all matching Elements for the applied identification logic. The Selenium API does provide additional functionality, such as waiting for an Element to be present, based on the identification logic. But this additional functionality still uses the base FindElement/FindElements fuctionality (As an example, when waiting for a match to a piece of identification logic, the DOM is polled with a defined poll interval and timeout.).

Selenium therefore provides the base functionality for UI interaction. < Need more here> If code attempts to interact with an identified Element that has changed, or been redrawn, since it was identified by Selenium, a 'Stale Element' error will be thrown; it is up to the Test code to deal with this itself - either by modifying the code to re-find the element before interaction, or respond to the error by failing the test or re-finding.

Controlium provides two basic additions. Element based and Control, or Component, based.

Element Based Additions

Controlium provides it's own Element type. The Controlium Element provides a higher level of Element interaction and control, as well as the base set of functionality provided by Selenium. The key additions are;

The Controlium FindElement can be configured to throw an error if the identification logic matches more than one Element. The functionality exposed by the Controlium Element type also allows testers to ignore issues that arise with HTML5 and more dynamic pages such as element Stalinity.

Whenever test code interacts with an identified element, Controlium monitors for a Stale Element error. If a Stale Element error occures, Controlium automatically re-identifies the stale element from the Parent Element or DOM root using the identification logic that was used in the original identification. If the Parent is also Stale, this is also re-identified. This occures recursivley to the DOM root and transparently (unless logging has been set to log Stale Element 'faults'). When resolved the original interaction required is applied. By removing the issue of Stale elements, test engineers can write highly interactive tests without having to deal with redraws or dynamic DOM HTML changes to the page.

Using element attributes and injected Javascript, Element functionality includes ability to know if element is currently moving on the page (IE. A menu may be dropping down and interacting with it while moving may have unexpected results). Adding to this, test code can wait until an element is stable on the page before interacting with it.

When Selenium throws an 'Another element would get the event' error (which means another element is currently covering the target element) it doesnt state what element is covering - making debug more difficult. Controlium, traps this error and identifies the element covering and adds this to the error information.

The Control Based Addition

At the core of Controlium is the HTML Control, or HTML Component. Most Web pages are now built using libraries of Components. Rather than developers writing raw HTML for every page, they use Components obtained from various sources. These components provide page functionality, such as tables, date boxes, text boxes (with labels and other atributes such as error messages, popup-tips etc). The Controlium 'Control' leverages this to greatly simplify page mapping and interactions. Before, the indentification logic for a textbox may have looked like "//div[text()='spouse-name']//input[@id='last-name']". For a table, the identification of cell elements could become very complex - especially if the functiomnality was such that the user could change column order and/or row order could not be guaranteed. Controlium Controls aim to simplify this greatly. Depending on the control, identification of a textbox may be as simple as SetControl(new TextboxControl("First Name:")) - IE. Using the human readable label 'First name:'. Or for a table cell SetControl(new TableControl("Sales"))["Month"]["June"]["Numbers Sold"] - Gets the Numbers Sold cell from the Sales table for the Month of June.

This removes the need for the tester, using the Controls in their test code, to understand XPaths or interact with the HTML in a low level. As an example, the Last Name text box above may have associated error-text that is shown if validation fails. In raw Selenium the code may get quite compex to check if the error is showing or verify the text; with Controlium the it can be as simple as isErrorShown = SetControl(new TextboxControl("First Name:")).IsErrorShowing; or errorText = SetControl(new TextboxControl("First Name:")).ErrorText;. The test code does not need to know how the error text is obtained, or even how the visibility is determined, as it is the resoponsibility of the TextboxControl code to do that work. By doing this, test coding becomes simpler, quicker to develop and much quicker to maintain (If, for example, the textbox component changes and the HTML changes =, only the TextboxControl code needs to be modified rather than all the instances where interactions with text boxes occures.

Clone this wiki locally