What is the difference between using System.Windows.Automation (commonly known as UIA) API and Microsoft.VisualStudio.TestTools.UITesting (one that is used in Coded UI Test behind the scene) for implementing UI Test automation of a WPF application programatically?
Is there any specific scenarios, restrictions or advantages/disadvantages?
In fact, the answer is in your question. UIA is used for automation, while UITesting is used for... testing.
An excerpt from MSDN:
UI Automation provides programmatic
access to most user interface (UI)
elements on the desktop, enabling
assistive technology products such as
screen readers to provide information
about the UI to end users and to
manipulate the UI by means other than
standard input. UI Automation also
allows automated test scripts to
interact with the UI.
Thus, UIA can be used for - but isn't limited to - UITesting.
Coded UI Tests are a framework which wraps many automation technologies. UIA is just one of them.
UIA is new in Vista/Windows 7 and it targets rich client apps, coded UI tests will use UIA when you write tests against WPF and Silverlight.
The advantage of Coded UI over using UIA directly is a lot of automatic retrys and knowledge of how UIA works is built into Coded UI tests.