June 14th, 2017 by inflectra
Take any tool for UI test automation and you will notice that they always lack support for some of the UI controls. And I am not talking about trivial ones like buttons and edit boxes, but the one that are custom controls, which are unique and created for specific needs. It can be some sophisticated grid or menu or a fancy tree. A number of such controls in this rapidly evolving world is growing exponentially. So, every UI test automation engineer is challenged by emerging UI frameworks in every project. This is especially true for Web applications.
As a provider of a UI test automation tool - Rapise - we constantly do our best to arm engineers with the most advanced technologies to help them deal with new UI controls.
This article by Danis Markovtsev will showcase a real-life example of this.
Our system under test is an enterprise resource planning (ERP) application from Microsoft - Dynamics 365 for Operations. It is cloud based and it works in a browser.
Why test the app? Did Microsoft do a lousy job and released bad quality product? I do not think so. I am sure Microsoft engineers did a great job and offer a high-quality solution. So, what's the issue here? We deal with an ERP application and every enterprise assembles this puzzle in its own way. Dynamics 365 for Operations can be configured, customized and enhanced in million ways. This is why testing of implemented workflow is a required thing. It can be tested manually or automated.
The first control you hit while using the app is the main menu.
Yes, everything displayed on the picture above is just a single menu object. It consists of two panels and each of them accommodates a tree of menu items.
To analyze the menu, one needs a Spy
that shows a DOM tree, allows to test XPATH and CSS expressions and we have one. Rapise even calculates XPATH of an element using different strategies. Notice Selectors
section in the property grid on the picture below.
Once the DOM of the menu is clear (see below, schematically) it is time for the next step.
<div class="modulesPane">
<div class="modulesList" role="tree">
<!-- Section of first-second level menu items -->
<div class="modulesPane-groupHeading" role="group" title="Modules"/>
<!-- Second level items, on the same level in the DOM tree as their parent! -->
<a class="modulesPane-module" role="treeitem" title="Procurement and sourcing" />
...
<!-- -->
...
<!-- -->
</div>
<div class="modulesFlyout">
<!-- Section of third-fourth level menu items -->
<a class="modulesFlyout-LinkGroup" role="group" title="Purchase orders"/>
<!-- Fourth level items, on the same level in the DOM tree as their parent! -->
<div class="modulesFlyout-link" role="treeitem">
<a class="modulesFlyout-linkText" title="All purchase orders" />
</div>
...
<!-- -->
...
<!-- -->
</div>
</div>
In Rapise one can define a complex object that spans across multiple DOM nodes. Using such a definition Rapise is able to recognize the object during recording and action on it during test playback. In terms of this example, given the proper definition of the menu control, Rapise is able to capture the menu object on recording and choose the desired menu item at run time. Looking ahead let me show how it looks in a test code:
SeS('MenuBar').DoMenu("Modules;Procurement and sourcing;Purchase orders;All purchase orders");
DoMenu
method receives a semicolon separated path in the menu.
Without special support for the menu, control life will not be so easy. During script recording user clicks will be captured as just clicks on some DIVs and links. And every choice of a target menu item will be dependent on 3-4 objects. This is not a resilient approach for several reasons:
Rapise helps to hide this complexity from testers who implement test cases. Coupled with Rapise Visual Language for scriptless automated testing it makes possible to engage non-programmers, for example, analysts and manual testers.
And now the most interesting part. Details of support for the menu in Dynamics 365 for Operations.
First, we define a new type of UI control.
/** @rule */
var DomDynamicsAXMenuBarRule = new SeSMatcherRule(
{
object_type: "DomDynamicsAXMenuBar",
object_flavor: "MenuBar",
extend_rule: "HTMLObject",
dont_hash: true,
/** @behaviors */
behavior: [DomDynamicsAXMenuBarBehavior]
}
);
Then explain recorder how to recognize the menu object. Here we define a callback that receives all the information about user clicks.
function IsDomDynamicsAXMenuBar(evt,element,eventOpts,objName,description, flavor, items)
{
var root = false;
if(root=__hasParentWithAttr(element, 'class', /modulesPane/ig))
{
// we are inside the menu!
// do the magic, e.g. calculate the menu path
// record action
}
}
Defining behavior stub.
/** @behavior */
var DomDynamicsAXMenuBarBehavior = {
actions: [
{
actionName: "Menu",
/** @action */
DoAction: DomDynamicsAXMenuBarBehavior_DoMenu
}
],
properties:
{
}
}
If you want to see the whole implementation of DomDynamicsAXMenuBarBehavior_DoMenu
get a trial copy of Rapise and look into
c:\Program Files(x86)\Inflectra\Rapise\Core\Engine\Lib\LibDomDynamicsAX\DomDynamicsAXMenuBar.js
.
Here I'll show an initial part that ensures that menu panel is shown on screen.
var menuPane = this._DoDOMQueryXPath('.//div[contains(@class,"modulesPane-flyout")]');
if (menuPane.length == 0)
{
var openButtonResult = this._DoDOMQueryXPath('.//div[contains(@class,"modulesPane-opener")]');
if (openButtonResult.length == 0)
{
return new SeSDoActionResult(false, false, "Open button not found");
}
var openButton = openButtonResult[0];
openButton._DoClick();
}
Modern Web applications continue to evolve and technologies used a while ago quickly become obsolete and new UI frameworks emerge. This leads to the appearance of a great number of complex Web UI components. The approach presented above enables automation engineers to rapidly add support for complex custom Web UI controls into Rapise. It makes further implementation and maintenance of test cases much easier, saves time and resources for QA teams.
rapise dynamics 365 test automation automated testing gui testing
Ask an Inflectra expert:
And if you have any questions, please email or call us at +1 (202) 558-6885
SpiraTest combines test management, requirements traceability & bug-tracking
SpiraTeam brings your teams together, managing the entire application lifecycle
SpiraPlan lets you manage your programs and portfolio of projects like never before
Orchestrates your automated regression testing, functional, load and performance
The ultimate test automation platform for web, mobile, and desktop applications
The help desk system, designed specifically for software support teams
Cloud hosted, secure source code management - Git and Subversion
Exploratory testing capture tool that automatically records your testing activity
Let us deal with the IT pain so you don't have to. Or use on-premise if you prefer.
Our customers work in every industry imaginable. From financial services to healthcare and biotech to government and defense and more, we work with our customers to address their specific needs.
Our products do not enforce a methodology on you, instead they let you work your way. Whether you work in agile development, Scrum, XP, Kanban and Lean, Waterfall, hybrid, or Scaled Agile Inflectra can help.
If you want to learn more about application delivery, testing, and more take a look at our whitepapers, videos, background papers, blog, and presentations.
Our suite of Accelerators speed up your deployment and adoption of our products, increasing your return on investment and reducing the cost of ownership.
We collaborate with a wide range of teams to bring our customers a range of services (including load testing, training, and consultation), complimentary technologies, and specialized tools for specific industries.
Learn how different organizations have benefited from using Inflectra products to manage their software testing and application develooment.
Outstanding support is the foundation of our company. We make support a priority over all other work. Take a look at our support policy.
Discover great tips, discussions, and technical solutions from fellow customers and Inflectra's technical experts.
If you can't find the answer you're looking for, please get in touch with us: over email, phone, or online.
We are constantly creating new videos to help customers learn about our products, including through in depth webinars, all freely available along with a wide selection of presentations.
We provide a number of resources to help customers learn how to get the most out of our products, with free online resources, virtual classrooms, and face to face.
Read about Inflectra, our manifesto, and values. Meet our incredible customers who are building awesome things, and our leadership team that are committed to building a great company.
The Inflectra Blog contains articles on all aspects of the software lifecycle.
In addition we have whitepapers,
background articles, videos and
presentations to help get you started.
Events are a big part of our awesome customer service. They are a chance to learn more about us, our products, and how to level up your skills with our tools.
We partner with educational institutions and individuals all over the world. We are also a great place to work and encourage you to explore joining our team.
Please contact us with your questions, feedback, comments, or suggestions. We'll get back to you as soon as possible.
When you need additional assistance (be it training, consulting, or integration services) our global certified solution provider partner network is ready to help.
At Inflectra, we are fully committed to provide our customers with the very best products and customer service. Check out some of our recent awards.
We want to help developers extend and customize our tools to fit in with their needs. We provide robust APIs, sample code, and open source projects.