Coded UI Test – Tip of the Day#5 – Copy reference of a control to clipboard

In Coded UI Test, you reference a control by its full hierarchy in the UI Control Map.

 

image

 

The above UI Control map shows the hierarchy of the Search Edit box in Bing.

If you wanted to *hand-code* some actions or verify properties of this control, you will have to type this full hierarchy. Even with Intellisense, this is tedious. NOTE: the default name for each of the controls in the hierarchy starts with UI.  You can select the desired control in the UI Control Map and click the “Copy Reference to clipboard” button to copy the full hierarchical name of the control to the clipboard. You can then copy this to your Coded UI Test file and perform actions or add assertions on its properties.

 

For the control highlighted above, the string below is copied to the clipboard.

UIBingWindowsInternetEWindow.UIBingDocument.UIEnteryoursearchtermEdit

 

PS: You may have to prefix this with the name of your UI Map.