In the Part 1 of this blog we looked at how the WPF 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

    

WPF Config Matrix

UITest Support for WPF is dependent on 2 Factors.

1. The accessibility technology Windows Automation API : Virtualization support is available only in Windows Automation API 3.0 (UIA2.0). We highly recommend that Users install Windows Automation API 3.0 before using UITest on WPF Applications. UIA2.0 is natively available on Win7 and Win2k8-R2. For all other DownLevel OS’s it can be Installed from here.

2. WPF Support For Accessibility: UIA2.0 Provides the Patterns that support Virtualization but the clientSide support for those are available only in .Net4.0. So the Applications built with .Net 3.5 wont work if the applications are virualized.

We also got lot of Bug-Fixes from the WPF team in .Net4.0 without which the UITest experience is not very good. Some of the fixes include

· The ElementFromPoint in .Net3.5 does not come out to be incorrect in lot of Places. This will result in Exception being thrown when we try to act on the control. There is a workaround for this issue see below table

· After doing a Scrollbar.Position on a ComboBox ScrollBar the Scrollbar becomes unusable.

· TextChange Events are not fired correctly leading to SetValue being not recorded correctly Sometimes.

· SetFocus on a Pop-Up Window causes the application to become Unusable.

 

 WPF_Version_Support_Matrix

As captured in the above Matrix we will work best only incase the Application is built on NDP4.0 and UIA2.0 is available.

 

Known Issues in WPF Area

Generic issues

1. The ElementFromPoint is returned incorrectly incase the Application has a XAML layout was like <Button /><Frame /> . In this Case UITest Wont work at all/.The workaround is to make the XAML Layout as <Frame /> <Button /> .

2. MenuItem Navigation is not correct unless the MenuItem has been expanded atleast once.

3. Aggregation of LaunchApplication of WPF ClickOnce application sometimes fails.

4. On a 64Bit XP machine Get/Set of Scrollbar doesn’t always return the correct Values.

5. Virtualized Controls may show some unintended Scrolls during propertyCalls.

6. If the Control is bound to a Object and it doesnot have ToString defined correctly we don’t record actions on the control as the Properties arenot enough to identify it correctly. Workaround is to define the ToString correctly.

7. ImplicitHover is not Supported.

8. Custom Control is not supported unless it implements accessibility.

9. Aggreagtion of Maximize breaks on a JPN VS in a EN OS.

10. The control is very heavily nested and we generate only 2 levels of ItemContainer leading to SearchFailure

 

Control Specific Issues

DataGrid

The DataGrid support is only available for Datagrids available with .Net 4.0.

Unintended Scrolling in Row and Column Virtualized Scenarios.

Drag of Column header fails in Column Virtualized Cases when it is dragged to something out of view.

ComboBox

Selection of a element using the Keyboard/MouseWheel doesn’t raise a SetValue at all times.

ComboBox Contained inside a ComboBox doesn’t work in MTM. It will work allright in CUIT.

Tab

Incase they are resized SendKeys action of {UP},{DOWN} wont work to select the Next Tab and subsequent actions will fail.

Controls Not Supported

WPF_Control_Support

 

 

Troubleshooting the UITest failures

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.

UISPY

The UI Spy tool enables developers and testers to view and interact with the user interface (UI) elements of an application. By viewing the application's UI hierarchical structure, property values, and raised events, developers and testers can verify that the UI they are creating is programmatically accessible to assistive technology devices such as screen readers. UISPY uses UIA and comes bundled with .NET 3.5.

 

Generic Debugging Tips

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

· Use the ScreenShot to validate that the control is in the correct state as expected.

· Draw a highlight using the DrawHighLight method to identify that the search has succeded.

 

UITest Exceptions

Following is the list of exceptions thrown from UITest and their possible root causes.

Recording Time Exceptions

TechnologyNotSupportedException

Thrown when a user is trying to record/playback on not supported configs. Currently we support only following technologies:

1. Web : (IE7/IE8)

2. Winforms

3. WPF

Common instance where this exception will be thrown are UITest on IE6, silverlight etc.

ApplicationFromNetworkShareException

If the AuT on which action is performed is a NetworkShare file. This is thrown during recording.

Playback Time Exceptions

ActionNotSupportedOnDisabledControlException

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

1. SetValue on a read only combobox/text box/rich text box

2. Click/SetState on buttons/checkboxes

FailedToLaunchApplicationException

Thrown when the fails to launch the app

1. Verify whether the recorded path is correct and app exists at that path

2. 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 SplashScreen, user can work around this in API playback by changing the path

DecodingFailedException

When the decoding fails due to incorrect key value, e.g., password encryption

UITestControlNotFoundException

This is thrown when the search for the control fails. In WPF we throw specific warnings incase this happens in the following scenario

· When any of the parent in the hierarchy is a ItemContainer it can be that the search has failed because all the elements in the Virtual Tree weren’t specified. In such a scenario User should use CUITBuilder/UISPY to move up the hierarchy and include all the Parent-ItemContainers. The Error Message from CodedUITest will explicitly mention this when this happens.

· If UIA2.0 is not installed on the box. User should install UIA2.0 as that is the mainline scenario and Virtual Controls Search will fail otherwise.

For generic Search Failure 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 UISPY

FailedToPerformActionOnHiddenControlException

This may happen specifically in WPF if the ElementFromPoint at that particular Point is wrong and is returning some Other control. Using UISpy verify that the correct control is being returned.

Other generic reasons may be 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

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

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

PlaybackFailureException

If the playback failure cannot be bucketized UITest identifies it as Playback Failure. This ideally should never come and this means that it is either

1. Unexpected Failure in the Application

2. ExtraOrdinary scenario which cannot be generalized.

 

Summary

In this blog we have seen the known issues with WPF plugin and how to troubleshoot failures using Accessibility tools like UISpy

 

Author – Rituparna Paul

SDET II - CodedUITest