Identifying dynamic content
The challenge
It can be tricky to identify content with dynamically generated attributes using Selenium. Dynamic content is based on dynamic identifiers (IDs). These IDs are generated anew every time an element is displayed, which makes it difficult to address the web element based on this attribute. For example, the IDs in web applications based on the “Yahoo User Interface Library” look something like “yui_3_8_1_1_13679224741219_543”. This ID changes every time the webpage reloads. In this case, you cannot use the ID locator to identify the element.
How to solve it
Ranorex comes with a set of RanoreXPath weight rules that automatically decide which attribute to use to identify objects based on particular web libraries. If you want to resolve a specific problem when identifying web elements, you can add a rule to this set. Please have a look at the blog post “Automated Testing and Dynamic IDs” for detailed instructions. Once added to the rule set, you can create your script-free or code-based test scenarios and run them on your WebDriver endpoints. As a result, the object repository will be automatically filled with robust repository items.
Dealing with timing issues
The challenge
Another challenge, especially when testing dynamic web applications, is handling timing issues – for example, when a query takes longer to provide the desired output. In Selenium, you have to manually implement a wait mechanism in code to overcome this issue.
How to solve it
Ranorex automatically creates search time-outs for each item in the object repository, providing a built-in safety net for possible timing issues. You can edit the search time-out of a repository item in Ranorex Studio (context menu item Properties). In addition to the automatically added search time-outs, you can explicitly wait for a specific element to appear or disappear using a Wait For Exist or a Wait For NotExist action in the actions table. You can get an overview of all possible actions as well as detailed information about specific actions in the section Types of Action Items in our user guide.
Maintaining web elements
The challenge
Test maintenance is dreary and, unfortunately, unavoidable. Especially in complex test scenarios, it can be difficult to maintain web elements addressed in your automated tests. When using a pure Selenium WebDriver implementation to automate your test scenarios, the same web element may be used multiple times. If this element changes, you then have to alter every occurrence of it manually. Even if you have used the page object pattern to manage web elements, you have to find the element that has changed and fix it in code.
How to solve it
In Ranorex, you can use the central object repository to manage your web elements. Every time an element in your application under test changes, you only have to edit it once and all changes will be automatically applied to all occurrences of this web element. To do so, select the desired element in the repository and open its RanoreXPath. Simply re-track the element using Ranorex Spy to successfully identify the element for future test runs.
Implementing data-driven testing
The challenge
Selenium WebDriver doesn’t have a built-in data-driven testing mechanism. This means you have to manually connect your automated tests to external data sources, read the data out of these sources and execute your test scenario with the added data if you want to data drive your tests.
How to solve it
Data-driven testing is already an integral aspect of Ranorex. Without any additional preparations, you can choose between several types of data connectors (simple data table, CSV file, SQL database and Excel file). Simply use the data from these external sources, to automatically execute your test cases with different data sets. You can find detailed instructions on how to perform data-driven testing in the dedicated user guide chapter.
Reporting
The challenge
An important aspect of any test automation environment is getting a detailed and easily understandable report for each test execution. When you use Selenium WebDriver, there are several possibilities to achieve a reporting mechanism. All of which, however, have to be implemented in code using third-party integrations.
How to solve it
Using the Ranorex Selenium WebDriver integration, you don’t have to worry about reporting. When you execute a website test on a WebDriver endpoint, a detailed Ranorex report will be automatically generated. This report provides you with a comprehensive overview of the entire test execution flow. As it is a JUnit compatible report, you can easily integrate it into any CI process.
As you can see, the matchless Selenium WebDriver integration in Ranorex Studio 7 allows you to finally use the best of both frameworks to your advantage and address common Selenium WebDriver pain points.