Coded UI Testing in Windows Forms Controls

11 Oct 20222 minutes to read

This section demonstrates how to create a simple test with TreeViewAdv. The Coded UI functionality can be tested from VS2010 or above with Ultimate or Premium version. TreeViewAdv supports Coded UI from Syncfusion Essential Studio version v9.1.0.20.

Creating Coded UI Project

CUIT should contain the Coded UI test project. When the Application does not contain the CUIT project, create a new project.

Creating the coded ui project

NOTE

The CUIT file is generated automatically, when creating the Coded UI test project. To add another test file, choose shortcut menu of the CUIT project, point to add, and then choose Coded UI test

Adding coded ui test case in coded ui project

Recording Steps

While generating code for Coded UI Test dialog box, choose the Record actions as shown in the following image.

Generate code for coded ui test

  1. After choosing the option, Coded UI Test Builder UIMap is shown at the BottomRight of the window.

  2. Choose the Start recording option from the UI Map to record the testing and it is also possible to pause the recording while testing the application.

Recording the actions using coded ui test builder

Pausing the actions using coded ui test builder

  1. The recorded steps can be viewed by using the UIMap or by pressing “Alt + S” key.

  2. To delete actions that was recorded by mistake, choose “Edit” Actions.

  3. To generate code that replicates performed actions, choose the Generate Code icon and type a name and description for CUIT method.

Recorded steps in coded ui test builder

  1. After completion of the testing process, choose the Generate code option from the UI Map to generate the code in the test project. The generated code replicates performed actions.

Generate code for recorded coded ui test

  1. Choose the required method and description for code generation.

Adding method description and name for record coded ui test

Testing Recorded Steps

The Application can be tested with the generated CUIT Method.

  1. Add a TestMethod named CodedUITestMethod1.

    public void CodedUITestMethod1()
    {
        // Generates code for this test. Select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        this.UIMap.RecordedMethod1();
    }
    Public Sub CodedUITestMethod1()
    	' Generates code for this test. Select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
    	Me.UIMap.RecordedMethod1()
    End Sub
  2. Build and Run the application that has already been configured. 

  3. Right click the body of the CodedUITestMethod and then select Generate Code for Coded UI Test -> Use CUIT builder as shown in the following screenshots.

Run the record coded ui test

UIMap coded ui test builder windows

  1. Now CUIT performs Recorded testing process.

Asset window for treeviewadv

Supported Controls

The following controls are featured with Coded UI Testing support.

Supported controls Levels
GridControl 4 Levels
GridGroupingControl 4 Levels
GridDataBoundGrid 4 Levels
TreeViewAdv 2 Levels
RibbonControlAdv 2 Levels
Carousel 2 Levels
RadialMenu 2 Levels
TabControlAdv 2 Levels
TabSplitterContainer 2 Levels