Recently, we were faced with a challenge of capturing Tooltip text on a Telerik WPF control using Microsoft Coded UI. It took considerable research, forum discussion and support tickets to arrive at an accpetable solution.
The Problem
Here is the dialog and the tooltip text which we were trying to capture -
The issue was, the tooltip "invalid value..." used to appear only on hover and even the new properties like ToolTipText when run on the WPF row / cell containing the wrong value, were not fetching the tooltip text. The primary reason for this turned out to be, the tooltip coming up from a hidden object and Coded UI Test Builder could not identify it.
Finding a Solution
Faced with the above situation, we decided to check if the cell with value ddf exposes any property which can be of help to us. Interestingly, Coded UI Test Builder could help us distinguish between the valid and invalid values using ItemStatus property. The values used to appear like this -
Error
-
CommitEdit!#!#True!#False!##7FADCDEF!#1!#0!#0!#False!#False!#False!#False!<and lot more text>
No
error -
CommitEdit!#!#True!#False!##7FADCDEF!#1!#0!#0!#False!#False!#False!#True! <and lot more text>
The String.Contains method could be used to validate the results but this approach lacked the elegance we were hoping for.
The Telerik Extensions
We then discovered Telerik's extensions for Coded UI which offered an elegant solution. The process began with installing two extensions (only WPF extension might be sufficient as the case may be) -
After installing the extensions, two DLLs (can be found in Telerik Binaries folder; refer Telerik VSExtensions Options from Telerik menu in Visual Studio) need to be referenced or registered -
This completes the pre-requisites. Now Coded UI Test Builder would be able to retrieve more properties. For instance, IsValid True or False for values in text boxes.
- Telerik.VisualStudio.TestTools.UITest.Extension.ExtensionsCore.dll
- Telerik.Windows.Controls
This completes the pre-requisites. Now Coded UI Test Builder would be able to retrieve more properties. For instance, IsValid True or False for values in text boxes.
How to use the Property?
- Define the object heirarchy as per your dialog design
- Define the objects as required Eg. WpfGridViewRow row = new WpfGridViewRow(table);
- Use the IsValid Property when necessary -
[WpfGridViewRow.PropertyNames.HelpText] = "GridViewRow";
if (row.IsValid == false)
That's all. Your function will start giving the right results!
Comments
Post a Comment