UITechnologyManager class

The UITechnologyManager class is responsible for the core services relating to the technology you are extending. This class must be visible to the COM. This is done by adding the [ComVisible(true)] Attribute to the class. A large number of the UITechnologyManager’s members if not implemented with are processed with a default algorithm.

1. Create a class that inherits the UITechnologyManager. Here I have grouped the members leaving out the important ones

image

Class Implementation

    public class SampleTechnologyManager : UITechnologyManager
    {
        public override string TechnologyName
        {
            get { throw new NotImplementedException(); }
        }

        public override int GetControlSupportLevel(IntPtr windowHandle)
        {
            throw new NotImplementedException();
        }

        public override IUITechnologyElement GetFocusedElement(IntPtr handle)
        {
            throw new NotImplementedException();
        }

        public override IUITechnologyElement GetElementFromPoint(int pointX, int pointY)
        {
            throw new NotImplementedException();
        }

        public override IUITechnologyElement GetElementFromWindowHandle(IntPtr handle)
        {
            throw new NotImplementedException();
        }

        public override IUITechnologyElement GetElementFromNativeElement(object nativeElement)
        {
            throw new NotImplementedException();
        }

        public override IUITechnologyElement ConvertToThisTechnology(IUITechnologyElement elementToConvert, out int supportLevel)
        {
            throw new NotImplementedException();
        }

        public override string ParseQueryId(string queryElement, out object parsedQueryIdCookie)
        {
            throw new NotImplementedException();
        }

        public override bool MatchElement(IUITechnologyElement element, object parsedQueryIdCookie, out bool useEngine)
        {
            throw new NotImplementedException();
        }

        #region Navigation Methods

        public override IUITechnologyElement GetParent(IUITechnologyElement element)
        {
            throw new NotImplementedException();
        }

        public override System.Collections.IEnumerator GetChildren(IUITechnologyElement element, object parsedQueryIdCookie)
        {
            throw new NotImplementedException();
        }

        public override IUITechnologyElement GetNextSibling(IUITechnologyElement element)
        {
            throw new NotImplementedException();
        }

        public override IUITechnologyElement GetPreviousSibling(IUITechnologyElement element)
        {
            throw new NotImplementedException();
        }

        #endregion Navigation Methods

        #region Search Methods

        public override object[] Search(object parsedQueryIdCookie, IUITechnologyElement parentElement, int maxDepth)
        {
            throw new NotImplementedException();
        }

        public override ILastInvocationInfo GetLastInvocationInfo()
        {
            throw new NotImplementedException();
        }

        public override void CancelStep()
        {
            throw new NotImplementedException();
        }

        #endregion Search Methods

        #region Add/Remove Event Mothods

        public override bool AddEventHandler(IUITechnologyElement element, UITestEventType eventType, IUITestEventNotify eventSink)
        {
            throw new NotImplementedException();
        }

        public override bool RemoveEventHandler(IUITechnologyElement element, UITestEventType eventType, IUITestEventNotify eventSink)
        {
            throw new NotImplementedException();
        }

        public override bool AddGlobalEventHandler(UITestEventType eventType, IUITestEventNotify eventSink)
        {
            throw new NotImplementedException();
        }

        public override bool RemoveGlobalEventHandler(UITestEventType eventType, IUITestEventNotify eventSink)
        {
            throw new NotImplementedException();
        }

        public override IUISynchronizationWaiter GetSynchronizationWaiter(IUITechnologyElement element, UITestEventType eventType)
        {
            throw new NotImplementedException();
        }

        public override void ProcessMouseEnter(IntPtr handle)
        {
            throw new NotImplementedException();
        }

        #endregion Add/Remove Event Mothods

        #region Initialize/Cleanup Methods

        public override void StartSession(bool recordingSession)
        {
            throw new NotImplementedException();
        }

        public override void StopSession()
        {
            throw new NotImplementedException();
        }

        #endregion Initialize/Cleanup Methods
    }

Let’s take a look at the important members first

Main Methods

  • TechnologyName – The unique and meaningful name that identifies the technology adapter.
  • GetControlSupportLevel – Gets the support level of this technology manager for the elements in the given window. The higher the value the stronger the support. Another way to think of this is the confidence level that this technology adapter has in supporting the window. The engine will simply pick the most confident.
  • GetFocusedElement – Should return the element that has focus within the window supplied. The element that has focus could be the window itself or a descendant of the window.
  •  GetElementFromPoint – Gets the element at the given screen coordinates.
  •  GetElementFromWindowHandle – Gets the element that is identified by the provided window handle
  • GetElementFromNativeElement – Gets the element from the native or underlying technology element such as IAccessable
  • ConvertToThisTechnology – Converts the given element of another technology to a new element of this technology manager. This is used for operations like switching between hosted and hosting technologies.
  • ParseQueryID – Parses the query element string and returns the parsedQueryIdCookie to be used later during Search() or MatchElement() or GetChildren() call for either searching or matching or getting children that has the same query string. When using Coded UI Tests the user specifies a series of PropertyName / Value pairs as the search properties. All of these together form the Search Query ID
  • MatchElement – Matches the element against the parsed query ID cookie provided by ParseQueryID.
    • A technology must support either MatchElement or Search
    • MatchElement has a dependacy on the GetPropertyValue method as the API uses this to get the value of the properties for matching
    • This is an optional method and if the technology manager does not support this method it should throw System.NotSupportedException exception. If the Search() is not supported then the framework uses GetChildren() API to do breadth-first traversal and for each element uses MatchElement() API to match & find. 

Other Methods

Advertisements
  1. Creating a Coded UI Test Extension « Ryan Burnham's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: