Thursday, May 29, 2014

Coded UI automation with Telerik RadBusyIndicator controls




One of my project is to build a WPF windows application, I used Microsft Coded UI technology to do UI automation. The tool I use is Visual Studio 2012 Ultimate.

To our principle developer's habit, he put Telerik RadBusyIndicator WPF control on every window to show a spin when the windows/controls are in busy status. Other developers follow the habit and put the control all over the modules. Following is a sample xaml code piece which has the control.

 <telerik:RadBusyIndicator IsBusy="{Binding IsBusy, UpdateSourceTrigger=PropertyChanged}"  
              telerik:StyleManager.Theme="Expression_Dark"  
              Grid.ColumnSpan="2"  
              Grid.RowSpan="2"  
              Panel.ZIndex="1">  
   <telerik:RadBusyIndicator.BusyContent>  
     <TextBlock Text="Processing..."  
           FontSize="13"  
           Foreground="WhiteSmoke" />  
   </telerik:RadBusyIndicator.BusyContent>  
 </telerik:RadBusyIndicator>    

Normally the control's size is big, cover the whole window or a range of controls, in order to prevent unexpected user actions while the window/controls are busy.

The reason developers use the control is understandable. The application we develop is a business application. Almost every window needs to query data from backend database. During the data loading period, we do not want user interact with UI elements.

What the issue is

Coded UI generated code always has playback failure.

Reason 

The RadBusyIndicator show a spin when window/controls are in busy status. But after the window/controls busy status changes to false, it's still exist, like a transparent mask on top of other controls.

Let me use a sample to explain what the issue is...

Here is an edit box A on a windows, and a RadBusyIndicator control B on top of A. I want to use Coded UI to generate the UI automation to input text "abc" in A. Normally coded UI generated code is like following:

A.Text = "abc
And when running automation, the playback will fail at
Here is the issue, any click on the UI, if
If someone used Coded UI Test Builder to record UI actions on the windows with the RadBusyIndicator WPF control, there comes the issue -- any recorded action has playback issue (actually when I click the control to put focus on, the So it caused the PROBLEM that when I do coded UI recording, all the action it captured is against RadBusyIndicator control. the code itall the mouse click on the

     /// <summary>  
     /// input - Use 'inputParams' to pass parameters into this method.  
     /// </summary>  
     public void input()  
     {  
       #region Variable Declarations  
       UITestControl uIPatientFirstNameEdit = this.UIGlidewellOfficeWindow.UIItemCustom.UIOrderEntryDataEntryCustom.UIPatientFirstNameEdit;  
       #endregion  
       // Click 'patientFirstName' text box  
       Mouse.Click(uIPatientFirstNameEdit, new Point(13, 8));  
       // Type 'abc' in 'patientFirstName' text box  
       Keyboard.SendKeys(uIPatientFirstNameEdit, this.inputParams.UIPatientFirstNameEditSendKeys, ModifierKeys.None);  
     }