Skip to Content
Technical Articles

Test Recording with UI5 Test Recorder

We are pleased to announce the availability of a long-awaited tool: the UI5 Test Recorder. Starting with UI5 1.74 it will help you build good OPA and UIVeri5 tests. The name stands for our bold plans but currently, it contains only a subset of the features we envision.

Motivation

One of the hardest parts when writing integration tests with OPA5 or system tests with UIVeri5 is building good selectors. A good selector is one that is easy to read and comprehend, works reliably and survives UI5 minor version upgrades. The easiest way to get these qualities is by using control locators that we introduced with UIVeri5 and recently (starting with 1.72) made available in OPA5 as well.

Manually building a control locator involves inspecting the control tree or sources of the application to be tested and deciding which properties or relations would be best to use in this particular case. With the time and number of tests you create, you gain experience which is the best strategy in every case.

Now, using the UI5 Test Recorder, you can easily generate a control locator. Just click on the control on the screen or in the control tree and that’s it! You can also choose between different formats – plain control locator or a statement in a format appropriate for OPA5 and UIVeri5, respectively.

Usage

The UI5 Test Recorder is part of the UI5 distribution and, therefore, automatically available in each and every UI5 application that uses UI5 1.74 or higher.

You can launch the recorder with a new key combination – ALT+CTRL+SHFT+T (SHIFT-CTRL-OPTION-T for Mac). Alternatively, you can also open it from the Support Dialog with ALT+CTRL+SHFT+P and clicking the “Start Test Recorder” button.

To build a selector for a specific control, just point it on the screen and right-click “Highlight”. This will mark the control in the control tree and the generated selector appears in the snippet section. You can also generate snippets for interacting with controls that involve clicking or entering text. Then you copy the snippet to clipboard and paste it in your text editor, where you compose your test script.

Algorithm

The control locator is derived by an algorithm that crawls the control tree and will evaluate a number of locators starting from global stable ID, ID in a view, Properties, LabelFor, I18NText and up to BindingPath, Ancestor and Descendent. We use a recursive search so if a unique selector can’t be derived on the current level, the search will iterate to a parent scope and evaluate again. If the selector can’t be generated in a predefined number of steps, you would see an error. Then, just try it on a parent control in the control tree. It is possible that a unique selector could not be generated within the constraints or deriving such locator would need semantical knowledge that is not available in the control tree. This is more likely in freestyle applications and in this case, you will need to inspect the control tree and build a control selector manually.

Recording

You may have worked with other tools that do test recording or visual test creation. We also consider adding such capabilities in our tool but such an approach has a major flaw when building tests. This is the temptation to record the scenario at once as a sequence of interaction and assertion steps and try to avoid building Page Objects for your views. Tests recorded in such a way are hard to modify and adapt to changes in the application or UI5. Our approach is to promote the usage of Page Objects and discourage the use of patterns that would hurt the quality of your tests in the long term.

Outlook

One area of improvement would be the coverage of more control hierarchy patterns, especially in freestyle applications. Furthermore, we plan to add a settings dialog with options to define preferences for selector generation. We also want to extend the support for building and consuming Page Objects. In the long-term, the aim is to live up the name of our tools and add more “recording” capabilities without sacrificing the test quality.

We would like to hear your feedback! Leave a comment under this post. Do you have any further questions? We are happy to answer them here or on StackOverflow. Found an issue? You are welcome to report it to GitHub.

4 Comments
You must be Logged on to comment or reply to a post.