UITest framework – Winforms Plugin - Part 2

In the Part 1 of this blog we looked at how the Winform plugin of UITest framework records and playback actions. In this blog we will look at known issues with this plugin and how to troubleshoot failures

 

Known Issues in Winforms Plugin

 

1. TreeView/ListBox/ListView

On Non-ENU OS where the default view is right to left (RTL) e.g., Arabic, the scroll bar for the treeview and list box controls are not accessible hence the EnsureVisible calls fail there.

2. Password Control

The playback would not clear the contents of password box before writing the value hence it may lead to incorrect password

3. Radio button

If the radio button is not in view port playback would try to do set focus on the control which results in selection of the item

4. DataGridView

Playback on DataGridView controls requires the state of the datagrid to be same as it was during recording, reason being we search for a row using its value (concatenated string of its cells' values)

5. DateTimePicker

In datetime picker we select a particular date using programmatic actions and then do sendkeys of Up and Down arrow. If the focus is on the year cell there are chances that after SendKeys of Up the month will get changed due to year change and after SendKeys of Down the wrong date will be set.

6. ListBox/ListView

1. ListBox before selecting an item we deselect the items programmatically, but if this fails we try to do this using mouse clicks this may affect the other thing if selection of a list item is hooked to some event

2. WFR calls can affect the SetValue event, eg., if hovering on a list item cause some tool tip to appear consistently playback would wait indefinitely for the set value action

3. In ListView two single mouse clicks first on the list item text and another just beside it (not on the text) leads to the set value (item) and then set value (empty). SetValue (empty) will fail during playback.

7. Menu items

1. Accessibility Issue: Some time even if the menu is collapsed state comes to be visible with some bounding rectangle, so playback tries to make bounding rectangle visible which fails as the menu is not expended.

2. Menu items : If the user clicks twice on a menu that leads the menu to collapse and start typing something on another control, our aggregator eats up the second mouse click and during playback the setvalue/sendkeys operation might lead to some invalid command to be invoked. e.g., in notepad two single mouse clicks on Edit menu item collapses the menu and then if you type “Restart” in the edit box, this will lead to invoke the replace command during playback.

8. ComboBox

1. DataBoundedComboBox: During playback we don’t wait for the combobox items to appear so if a combobox is binded with some database and loading of the combobox items take time, the playback may fail with SearchFailure for the combobox item.

2. If a combobox selected value is coming out to be different from the actual combo box items, the playback would fail. As playback searches for the value in the items which would not be there.

 

Troubleshooting the UITest failures

The two most common categories of failures in UITest are due to search failure or action failure. User can get help from some existing tools to look into the properties and hierarchy of the controls and the events which are being used by UITest during recording.

Tools to debug the accessibility/search issues

Following are some of the important tools which can be used to debug the accessibility/search issues during record/playback.

 AccExplorer

This tool depicts the complete UITree of the AuT with important properties exposed through MSAA. This can help to get an idea on the UITree of AuT and the MSAA properties for different controls.

Spy++

Using AccExplorer user cannot get to know the Win32 properties of Win32 controls. As UITest uses both Win32/MSAA search mechanism so sometime this tool is also useful to see the Win32 properties of a control.

AccEvent

This is used to get the details of the events fired from controls while doing actions on them. UITest is dependent upon the events fired from the controls to record the actions. E.g., SetValue on a control is recorded after receiving ValueChange event from the edit box.

These tools can be downloaded from the following location:

https://www.microsoft.com/downloads/details.aspx?familyid=3755582A-A707-460A-BF21-1373316E13F0&displaylang=en

Here are some of the guidelines to troubleshoot the failure during recording/playback.

 

Recording Time Failures

Possible Exception

Cause

Comment

TechnologyNotSupportedException

Recoding on a unsupported technology App

As mentioned above Winforms/WPF/Web are three different kind of technologies supported by UITest so if user tries to record on some other technology we fail with the following exception.

ApplicationFromNetworkShareException

Recording on a Network share application

This occurs when the recording is being done on a network share App.

 

Playback time failures

Playback does two major things in order to perform action on the control search and action on the control. Following are the possible reasons and their exceptions.

SearchFailure

Following are some of the suggested tips to debug the search failure during playback.

· See screenshot (stored in %temp%\uitestlogs\lastrun if logs are enabled) to see whether the control was actually visible or not.

· Verify the search properties and UI hierarchy (QueryID) using AccExplorer.

Possible Exception

Cause

Comment

UITestControlNotFoundException

The control does not exist or search properties are not enough to find the control

User can use AccExplorer and see whether the search properties and the hierarchy are correct

UITestControlNotAvailableException

The control does not exist in the app now.

If the control has been invalidated or deleted during the playback, the window handle and other properties related to it would be invalid then.

Action Failure

Sometime though the search passes but the playback may not be able to do the action on the control. Following may be the possible reason/tips to debug the issue

· Verify using AccExplorer whether, is there any other control with the same properties under the parent mentioned in the QueryID. Some time there may be more than one control with the same properties under a parent hence during playback the first control will be selected and the action may fail on it. User can work around it after adding the instance property in the code for the ambiguous control.

· User can use .DrawHighLight() method to actually see which control is chosen for the UITestAction. This method is available for all the UITestControl and will draw a rectangular highlighter around the control.

· The playback may fail to act upon the control if it failed to bring the control to the view port. E.g., if a button is scrolled out and its container is not scrollable there is no way to do a click on the button hence the playback will fail.

· Verify whether the control state is same as it was during recording e.g., SetValue was recorded on a text box but during playback the text box is read only.

AccEvent can be used to find if the control is firing proper events for the user actions or not. You can attach AccEvent with a specific WindowHandle value and see what all the events are fired from that control. For example for a text box one can verify whether ValueChange event is fired from the control or not if it is not fired we won’t be able to record SetValue on the control.

Possible Exception

Cause

Comment/Possible workarounds

ActionNotSupportedOnDisabledControlException

Playback is trying to perform action on a disabled control

This is thrown when the playback try to do some action on the disabled control/read only controls. Following are some of the cases:

· SetValue on a read only combobox/text box

· Click/SetState on buttons/checkboxes

FailedToLaunchApplicationException

When the playback fails to launch the AuT

Verify whether the LaunchApp was recorded on the original exes or on some other file e.g., sometime if a App launches SPLASH screen before the original AuT LaunchApp is recorded on splash screen, user can work around this in API playback by changing the path

FailedToPerformActionOnBlockedControlException

The control exists but not actionable

Thrown when a control is blocked in this case though the search passes but the required action will not be played back. Following might be some of the causes for this exception

· The control is not visible in the view port and not scrollable even

· Control is blocked due to some modal dialog on top of it

DecodingFailedException

May come in password text box

When the decoding fails due to incorrect key value in password encryption.

PlaybackFailureException

Default fall back exception for uncategorized issues

For any other failure the playback engine would throw PlaybackFailureException. For example if Get/Set of some property fails for a control playback engine would throw PlaybackFailureException.

 

Summary

In this blog we have seen the known issues with Winforms plugin and how to troubleshoot failures using Accessibility tools like AccExplorer etc.,

 

Author – Deepak Singhal

SDET - CodedUITest