Although I ended my Selenium adventure a few months ago, there is a final topic I’d like to cover here. This one completes my set of posts concerning RadControls for ASP.NET AJAX test automation with Selenium. The tool, the Telerik ASP.NET QA team relied on during the past couple of years, helped us catch in time most of the bugs in RadControls that never came into production!
A curios fact here is that Selenium 1.0 official release is finally coming soon after many years of development! Check out the recent post on Selenium blog announcing the exciting news.
Finally, as promised, this post presents the idea of extensibility in test automation including several examples of Selenium extensions for RadControls (ASP.NET AJAX).
I personally consider the simplicity of Selenium Core tests as a plus in tests suite creation. Additionally, the Selenium Command Reference allows building of powerful tests even over complex Web applications based on RadControls. We expanded the ease of test creation and maintainability with the help of further commands.
The concept of extending the command reference in Selenium is explained here, so I will not cover the basics. However, it’s important to put the attention to an option: defining just a single command via Selenium.prototype.getFoo and isFoo definitions builds several other and useful command variations – store/assert/waitForFoo and their negative counterparts. That’s helpful especially in building composite tests and such dealing with AJAX applications.
The sample extensions described in this post has never been published anywhere despite my willingness to contribute more to the Selenium community. I have also changed the original code a bit for the sake of simplicity.
There are two groups of commands– some of them are general that can be used outside the RadControls applications and the others, the core of our extensions, are specific to each component. Let me start with the first group.
I can’t imagine dealing with complex HTML without table commands. Some of the first extensions I found myself in bad need were the next two samples. Those get the count of table rows and the row cells. When you look at their simple definitions, you can’t imagine how often one may need them!
Note: as an alternative, the latest Selenium Core version 0.8.3 exposes a new build-in command – storeXpathCount. One needs to specify an exact XPath script as an argument to verify the count of the matching elements. The above commands however are much easier for use, examples follow:
The test above asserts that RadGrid data table of the application under test consists of two rows, the second one (having index '1’) contains five cells.
Here is an interesting sample verifying the value is in the given range.
It can be used as follows:
as ‘min’ and ‘max’ are exact numbers.
Let me pass to some examples for ASP.NET AJAX applications. The first one serves as a helper function to get a real client-side object from the AJAX page. We call the ‘$find’ function to get the AJAX object from the tested page:
Now we can go on and build a set of commands for each component in the RadControls suite. Both actions and verifications of the client-side tests use the components API due to the controls specific behavior. I discussed this in The Trickiest Tips in RadControls for ASP.NET (AJAX) Tests Automation post. So instead of evaluating complex single-line scripts, one can put that script in a separate helpful command:
and use it in the tests:
Of course this also allows easy debugging of the script error.
More RadGrid Selenium extensions follow:
The commands can also serve as actions executing client-side API methods. An excellent example is the use of the RadEditor object’s set_html() method:
and the respective verification comes here:
Here is a sample Selenium Core test operating with the RadEditor client-side object:
I cannot miss the last item from the “trickiest tips” post: an alternative to select and get the selected item text of RadComboBox:
And a sample test case:
I think this gives the basic idea behind the Selenium Extensions used in RadControls application tests. Should you need a particular command, do not hesitate to drop us a line and we will do our best to help.
This is a classic example of extensibility in Web-based test automation helping simple structured tests to cover complex applications and their components. I wouldn’t say you can get this as a perfect solution in test automation of RadControls applications but it is definitely a good base to compare with.
Once again, here is a quick reference of the set of post about RadControls application testing with Selenium:
Subscribe to be the first to get our expert-written articles and tutorials for developers!
All fields are required