[8.0.100-preview.4.23253.2] WinForm Application's Window control type changed from WinWindow to Caret in Coded UI Test
See original GitHub issue.NET version
8.0.100-preview.4.23253.2
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Yes
Verify Scenarios: 1). Windows 10 21H2 AMD64 + dotnet-7.0.300-rtm.23215.1: Pass 2). Windows 10 21H2 AMD64 + dotnet-6.0.409-servicing.23215.9: Pass 3). Windows 10 21H2 AMD64 + dotnet-sdk- 8.0.100-preview.4.23225.2: Pass 4). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.100-preview.4.23253.2: Fail 5). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.100-preview.4.23259.1: Fail
Issue description
Application Name: More than 30+ apps affected (paintnetcore, ConicSectionPlayground, Core2D, DragonEngine, EnvelopeWarpPlayground, Estoque, GameofLife, GlucoseTray, Greenshot and so on) OS: Windows 10 21H2 CPU: X64 .NET Build Number: dotnet-sdk-8.0.100-preview.4.23253.2 Checking repro machine at : https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1816978
When automation testing for WinForm applications in Coded UI Test, the recorded root control type is changed from WinWindow to Caret starts from dotnet-sdk-8.0.100-preview.4.23253.2. It results to automation code cannot find controls under this root when applications running on dotnet-sdk-8.0.100-preview.4.23253.2. There are more than 260+ test cases (more than 30+ apps) are affected and all these test cases must to be re-designed.
Repro Video:
On default .NET 6.0 runtime, the operated control type is WinWindow. And check from the UIMap.uitest designer page, it also shows the root controls is
WinWindow uIForm1Window = this.UIForm1Window;
// Maximize window 'Form1'
uIForm1Window.Maximized = this.MaxNET6WinFormWindowParams.UIForm1WindowMaximized;
Start from dotnet-sdk-8.0.100-preview.4.23253.2, the root control type becomes Caret and the operated control becomes the Button under Caret > TitleBar > MaximizeButton.
WinButton uIMaximizeButton = this.UIForm1Caret.UIItemTitleBar.UIMaximizeButton;
// Click 'Maximize' button
Mouse.Click(uIMaximizeButton, new Point(22, 17));
Steps to reproduce
Minimal Repro steps on repro machine:
1.Launch the demo app “C:\WinFormsAppDemo\WinFormsAppDemo.exe” 2. Open VS2017 and create a default Coded UI Test Project. 3. When Generate Cod for Coded UI Test window appear, click OK button. 4. Click Record button to start recording actions. 5. Click the Maximized button on WinFormsAppDemo app window. 6. Click Generate code button. 7. Set name for the record method. 8. Stop the recording and check the generated code. 9. Go to the UIMap.Designer.cs, and check the recorded method. The root control is WinWindow.
WinWindow uIForm1Window = this.UIForm1Window;
//Maximize window 'Form1'
uIForm1Window.Maximized = this.MaxNET6WinFormWindowParams.UIForm1WindowMaximized;
- Change the WinFormsAppDemo.runtime.config file from 6.0.0 to run against with SDK dotnet 8.0.100-preview.4.23253.2:
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.0-preview.4.23228.5"
},
{
"name": "Microsoft.WindowsDesktop.App",
"version": "8.0.0-preview.4.23252.6"
}
]
- Repeat steps 1~8.
- Check the recorded code, the root control type is Caret:
WinButton uIMaximizeButton = this.UIForm1Caret.UIItemTitleBar.UIMaximizeButton;
// Click 'Maximize' button
Mouse.Click(uIMaximizeButton, new Point(22, 17));
Expected Result: The control type is same.
Actual Result: The Control type is changed from WinWindow to Caret.
Issue Analytics
- State:
- Created 4 months ago
- Comments:8 (6 by maintainers)

Top Related StackOverflow Question
@Olina-Zhang, @dmitrii-drobotov you both rock! 🙇🏼
Verified this on .NET 8.0 test pass build: 8.0.100-preview.5.23276.4, issue was fixed, test result is same as above result.