Articles in this section
Category / Section

How to perform the CodedUI testing in WinForms TreeViewAdv?

3 mins read

CodedUI testing

You can perform the Coded UI Test (CUIT) in the TreeViewAdv can be used for testing purposes.

TreeViewAdv:

The Essential Tools TreeViewAdv control has basic level of Coded UI automation testing support. 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. Refer to the following steps to provide Coded UI support in the TreeViewAdv.

Create a Coded UI test project:

CUIT should contain the coded UI test project. If your application does not contain the CUIT project, create a new project. In the Solution Explorer, on the shortcut menu of the solution, choose Add, New Project, and then select either Visual Basic or Visual C#. Next, choose Test, Coded UI Test.

In case, the Coded UI test project does not appear on Visual Studio, you may be using the version that does not support CUIT. To create CUIT, you need to use Visual Studio Enterprise edition.

Creating test application

Figure 1: Creating Test Application.

Adding Coded UI test file:

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 CodedUITest file to the test project

Figure 2: Adding “Coded UI Test” file to the test project

  1. In the Generate Code for Coded UI Test dialog box, choose the Record actions as shown in the following image.

 

Recording option to generate code for CodedUITest

Figure 3: Recording option to 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 start recording option from the UI Map to record the testing. You can also pause the recording while testing the application.

 

Start recording from UIMap

Figure 4: Start recording from UIMap

 

Pause recording from UIMap

Figure 5: Pause recording from UIMap

  1. The recorded steps are shown by using the UIMap or by pressing Alt + S key.
  2. To delete actions that you had recorded by mistake, choose Edit Actions.
  3. To generate code that replicates your action, choose the Generate Code icon and type a name and description for your CUIT method.

Record steps shown in UIMap

Figure 6: Recorded steps shown in UIMap

  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 your actions.

Generate code in UIMap

Figure 7: Generate code in UI Map

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

Generate code window for UIMap

Figure 8: Generate code window for UI Map

Testing application with the Generated Coded UI Tests:

You can test the application with the generated CUIT method.

1. Add a TestMethod called CodedUITestMethod1.

C#

[TestMethod]
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();
}

VB

<TestMethod> _
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. You can also open the CUIT builder with the following steps.

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 screenshot:

Opening Coded UI Test builder

Figure 9: Opening Coded UI Test Builder

show Coded UI Map

Figure 10: Coded UI Map

Assert window for TreeViewAdv in Coded UI Test Builder

Figure 11: Assert window for TreeViewAdv in Coded UI Test Builder

Samples:

C#: TreeViewAdv-CodedUISupport_C#

VB: TreeViewAdv-CodedUISupport_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied