This article describes how to use the Ranorex Studio IDE and the Ranorex API for test automation in your behavior-driven development (BDD) process. BDD requires a cognitive shift: instead of thinking about testing functions, you are now thinking about behaviors....
Dynamic IDs: a Challenge for Recognition
In the HTML standard, any element within an HTML document can have a unique identifier (ID). This identifier is provided in the id attribute of the element. To automate web elements with Ranorex, the id attribute is one of the best selectors for reliable and stable test automation; moreover, it defines the priority when a RanoreXPath is built.
If you’re working in web development, chances are that the website or application to be tested uses dynamic identifiers. This may be because your application works with dynamic content. Imagine a social network page that displays posts, each of them having a share button. To maintain the uniqueness of the ID attribute, it’s necessary to randomly generate a value for each button or, more commonly, to omit it. Furthermore, there are various web frameworks which assign dynamic IDs to the UI elements they generate.
For test automation, this provides a challenge: if you incorporate a dynamically generated, random ID in the RanoreXPath of your repository element, chances are that next time you access the website or application this value changes, leaving you with unstable test automation. This is not a new topic. Ranorex Studio has automatic ID detection algorithms for known web frameworks. Additionally, you can alter path weights and give less priority to the otherwise preferred id attribute when running into problems with dynamic IDs.
Intelligent Web Element Recognition in Ranorex Studio 9.0
The number of technologies and solutions for the web is increasing every day. Not only are frameworks generating dynamic IDs, but also developers are doing so when creating new websites and applications. It’s hard to keep track of all the different solutions available and reliably identify them. To conquer this problem, Ranorex Studio 9.0 features a radically different approach to identify elements.
The development team at Ranorex created a large collection of thousands of different websites and frameworks. We used this collection to train a deep learning AI to distinguish between static, i.e. man-made, and dynamic IDs. Based on this, Ranorex Studio 9.0 provides you with an intelligent system that can reliably decide if the id attribute of an element is dynamic; or not.
When you use Ranorex Studio to detect an element on a website that features an id attribute, the new intelligent algorithm will classify its value as dynamic or non-dynamic. Depending on this outcome, the resulting RanoreXPath will then automatically adjust the priority and include the id attribute only if it makes sense. Our system is smart enough to even distinguish between nuances like button1 and button000001; the latter being dynamically generated by a web framework. This helps to create more reliable and stable tests and reduces the maintenance effort for you as a tester.
Enabling and Disabling the Machine-Trained Element Recognition
If you have Ranorex Studio 9.0 installed, you can start using this new feature right away: It is activated by default. This feature is compatible with new and existing test suites alike. If you want to check for unstable RanoreXPaths in your existing test suite, try the maintenance mode.
We know that there are endless possibilities in software development. Should you observe any unwanted behavior or mismatched inclusion of your web elements’ id attributes, you can adjust the behavior in the advanced options and disable the intelligent algorithm there.
With our new, machine-trained algorithm for element identification and classification, you can now automate your website or app with Ranorex Studio 9.0 with a lower risk for automation failures. This empowers you to create reliable tests even faster – and minimizes your maintenance effort.
The SpecFlow add-in provides file templates for feature files, step definition files and event definition files. It also translates the features from Gherkin syntax to C# code. To install the SpecFlow add-in to Ranorex Studio, follow the instructions below:
Test driven development is a type of programming that relies on testing and coding as well as design to work as one.
Test maintenance ensures the quality and accuracy of an application is not compromised. Uncover how to ensure your tests are always up to code.