June 20th, 2017 by inflectra
Web applications are a perfect example of a rapidly moving target for UI test automation tools. Agile and DevOps drive small changes and frequent releases. This leads to certain challenges in QA field. How to create tests that survive after small UI changes? How to create tests that produce same results if ran 10 times in a row on an unmodified application? How to create tests that check exactly those features they were designed to check?
Answers to these questions are not entirely simple. Test automation is still an art.
In this blog we try to figure out what every test automation engineer can do to find the right answers. First I'll give a few examples that illustrate common challenges in Web UI test automation.
Assume that you have a page with Log In
button and the test relies on
/html/body[1]/form[1]/div[3]/div[2]/div[2]/p[1]/input
xpath expression to find it. Imagine that a new element is inserted before this button. The xpath expression (selector) becomes invalid and the test breaks. Is it a good selector? I would say No. Can we do better? Sure, if the button has ID attribute specified we can use
//input[@id="MainContent_LoginUser_LoginButton"]
With this selector no matter what is inserted/modified on the page - if Log In
button is there - the test will find it.
So, selectors matter.
Every Web application loads data from somewhere. It can be a database, third-party REST service or a banner network. And nobody knows how fast a web page is loaded and its elements are ready to use. So, an automated test must take into account various delays and be patient. Otherwise, the test may be useless as it will provide pass and fail results under the same circumstances.
Tests perform checks. Aristotle would call it telos
of tests. Let's compare two assertions:
Which one is better? Of course, the second assertion may lead to many confusions with the test. It will fail on a screen with a smaller resolution, it may produce a false positive result on a 5K Retina display.
The second assertion is weak. And the first one is strong.
A good test is a resilient test with strong assertions, it must meet the challenges presented above. Of course, there may be exceptions, but they are a minority.
What may help with building resilient tests for Web applications?
All modern browsers have private/incognito mode that makes you feel that you are running a web application for the first time. No cache, no cookies. It may help an automated test to enter the same water again and again and produce a steady result.
In Rapise - test automation tool that we develop - we have an XPATH generator integrated into Spy which automatically produces several xpath alternatives for a given DOM node. For example:
/html/body[1]/form[1]/div[3]/div[2]/div[2]/p[1]/input
(//input)[9]
//input[@id="MainContent_LoginUser_LoginButton"]
//input[@value='Log In']
By looking at xpath variants a test engineer can quickly choose the best one or produce a derivative.
It is nice to have an ability to specify a set of selectors that may be used to identify a particular element in the application. If some selectors are broken there is a chance that at least one is still valid.
Use wait statements preferably with a timeout to delay test execution util an element is available for interaction. Such waits can be explicit or implicit if, for example, a test engine tries to find an element on a page several times with a specific delay between lookup attempts.
Sometimes passing a click using DOM event does not work. In this case, it is useful to have a way to simulate a physical click.
Software developers may also help with building resilient tests. They can make life of QA teams much easier by
Building resilient tests is a key to successful UI test automation. If your tests are brittle better go with manual testing approach otherwise you'll spend too much time fixing those failing tests. Of course, right selection of an automation tool is also important. It should support you down the road of resiliency.
Rapise UI Testing Test Automation Web Applications Inflectra
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 organizations to bring our customers a range of services (including load testing, training, and consulting), 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.