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.

SSL VPN: Configuring and Using Forticlient on Ubuntu, creating a Launcher

Is your primary OS at home Linux and do you use Windows only to connect to your work PC over VPN or to attend meetings?  Do you often wish to connect to your work VPN from a Linux PC?  If your answer is 'Yes' to the above questions, I have an answer if your workplace uses Fortinet SSL VPN. Note that it's possible to connect to Fortinet and other VPNs like Cisco VPN from Linux through the inbuilt network manager by installing additional tools but this post would focus on using the standard Forticlient for accessing the resources on your work network. Obtaining Forticlient The most important thing to note w.r.t. using Forticlient for Ubuntu (or any Linux distro) is to note that the client is not publicly available for download from the official website. You will have to ask your IT department to download the client for you, in case they haven't provided it.