The list below is a step by step guide to the important parts of creating a Coded UI Test Extension. I will be discussing each step in-depth in upcoming posts.
Communication between your extension and your application
- Create a new Class Library project
- Add the necessary references
- Add the UITestExtensionPackageAttribute to inform the UI Test Framework that there is an extension in this assembly.
The property provider is used in the Spy tool so we will start with getting this working.
- Add a class that inherits the UITestPropertyProvider class. This class provides information about the corresponding UI element can have and gives a way to get/set those properties
- Add support for the GetControlSupportLevel method. This method is similar to the UITechnologyManager.GetControlSupportLevel method. It provides the engine a way to find the best Property Provider to use for a control dynamically.
- Add Support for GetPropertyNames method. This method gets the name of all the controls supported by this Property Provider.
- Add Support for the GetPropertyDescriptor method. The descriptor gives information about the type of property, which category it belongs to (used in the Spy control to group properties) and the attributes (like readable, writable and searchable)
- Add support for the GetPropertyValue and SetPropertyValue. These methods are used to get or set the property by the engine.no check is done on the engine for the property name or
- Create a class that inherits from the UITestExtensionPackage. This is the entry point to your extension
- Add support for the GetService method. This method returns a class implementing one of the extension points, such as UITechnologyManager
- Add support for the Dispose method, used to do any sort of resource clean-up.
- Add support for the PackageDescription, PackageName, PackageVendor, PackageVersion, VSVersion properties
- Create a class that inherits from the UITechnologyManager abstract class
- Add the CommVisible attribute to the class to make it visible to the COM
- Add a Unique and meaningful name to the TechnologyName Property
- Add logic to the GetControlSupportLevel method to determine how confident the extension is at supporting this specified control. The engine uses the most confident extension
- Add support for the GetFocusedElement, GetElementFromPoint, GetElementFromWindowHandle, GetElementFromNativeElement and the ConvertToThisTechnology methods. These methods are the different ways the engine can ask for technology specific information.
- Add Support for the PaseQueryID method which helps with performance by parsing the Search Query ID by parsing it once and caching it for further use.
- Add Support for the Search method and its fall back MatchElement method. These two methods can be used to find an element
- Add a class that Implements the UITechnologyElement. This class is responsible for representing a UI Element for the technology being extended.
- Add support for the QueryID property. This is made out of a property name\value pair that is needed to uniquely identify the control. The technology author is responsible to come up with a good query id that will handle situations like duplicate controls.
- Add support for the CacheProperties method. This method is called during recording to capture important properties and cache them so they are available to the engine after the UI disappears.
- Attach to the QTAgent32.exe process and set break points to debug during playback and CodedUITestBuilder.exe to debug during recording /assertion and code generation