question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:
CodedUIRepro

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));

image

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;
  1. 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"
      }
    ]
  1. Repeat steps 1~8.
  2. 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.

@dotnet-actwx-bot @dotnet/compat

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
JeremyKuhnecommented, May 11, 2023

@Olina-Zhang, @dmitrii-drobotov you both rock! 🙇🏼

2reactions
Ashley-Licommented, May 31, 2023

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Untitled
... 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.
Read more >
Untitled
GitHub Witryna6 maj 2023 · Windows Forms (WinForms) is a UI framework for ... in Coded UI Test, the recorded root control type...
Read more >
Untitled
Microsoft.dynamics.framework.ui.winforms.controls C# Using Microsoft. ... Coded UI Test, the recorded root control type is changed from WinWindow to Caret ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found