Monday, 9 February 2015

Record one application only in CodedUI Test

Generally, we test a single application using Coded UI Test. By default, Coded UI Test though will record actions on all applications.  Thus we may get unwanted actions on other application in our recording.

We can prevent this by adding the following configuration in CodedUITestBuilder.exe.config file
<add key="IncludeProcess" value="%SystemRoot%\system32\calc.exe"/>

Replace calc.exe with the full path to your application. With this configuration only actions on calc.exe (or the application that you added) will be recorded.

When using IncludeProcess, actions on the Windows desktop are not recorded. If you want to include actions on the Windows desktop, add the following configuration.
    <add key="RecordOnDesktopProcess" value="true"/>

Alternately, we can also selectively exclude applications from recording using the following configuration.
<add key="ExcludeProcess" value="%SystemRoot%\system32\calc.exe"/>
Replace calc.exe with the full path to the application you want to exclude from recording.

NOTE: These settings are applicable for Recording only. We can still drag the cross hair onto any application, get its properties and add assertions on them.

If you see that no actions are being recorded on a particular application, first check this config file to ensure that the application has been added in the ExcludeProcess section. Also verify the IncludeProcess  configuration. If a particular process has been added in IncludeProcess, then actions on your applications will not be recorded.

It is possible (though not recommended) to add process ids to IncludeProcess & ExcludeProcess configurations.

No comments:

Post a comment