Skip to main content

Validating entries in a WPF dialog using Coded UI and Telerik Properties

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 -

  1. Telerik.VisualStudio.TestTools.UITest.Extension.ExtensionsCore.dll
  2. 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?

  1. Define the object heirarchy as per your dialog design
  2. Define the objects as required Eg. WpfGridViewRow row = new WpfGridViewRow(table);
  3. 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

Popular posts from this blog

Turning off a Dell Laptop Monitor: Keyboard shortcut(s)

I am someone who is particular about power savings and I don't leave appliances powered on when not in use. The same applies to computing devices - be it a smartphone or a PC/Laptop. I power off the desktop monitor when I step out for a tea break or hit Fn+F2 on my Lenovo laptop that turns off the display. Recently, I got a Dell Laptop and I was surprised to discover that Dell does not provide any shortcut to turn off the display. This led to some exploration and I found two ways to achieve that which are outlined below - 

Resolving INS-20802: Oracle Net Configuration Assistant failed error on Windows 10

I was all excited about the migration to Windows 10 until I had to install Oracle client 12.1.0.2 on it. The Oracle client installation used to fail miserably at the last stage with this error named INS-20802.

Nginx - Solution for 10060: A connection attempt failed because the connected party did not properly respond

I was in the process of setting up Nginx to serve as the reverse proxy for Nexus Repository Manager OSS. However, the Nexus repository started loading really slowly post this and used to repeatedly display disconnected and reconnected messages. The Nginx log file used to log the below error - <timestamp> [error] 3240#3632: *1 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: <ip address="">, server: <fqdn>, request: "GET /nexus HTTP/1.1", upstream: "http://[::1]:8081/nexus", host: "<fqdn>"