Use the Wizard to create a custom Activity - C#

Relevant for: API testing only

This task describes how to create a new activity, using C#, and deploying it in UFT.

Run the Activity Wizard

  1. Open the Activity Wizard (Start > All Programs > HPE Software > HPE Unified Functional Testing> Tools > Activity Wizard or <UFT installation folder>\bin\ActivityWizard.exe).

  2. In the wizard's General Properties pane, select the C# as the Language.

  3. Follow the steps of the wizard to create your activity.

Back to top

Add execution code

  1. In the final screen of the wizard, click Open Folder to open the <Activity Name> folder, corresponding to the activity name you specified in the wizard. Navigate to the SourceCode subfolder and locate the <Activity Name>.cs file.

    Caution: Do not close the Activity Wizard after this step.

  2. In the <Activity Name>.cs file, add your execution code to the ExecuteStep function, as follows:

    protected override STExecutionResult ExecuteStep()
    {
    try
    {   
    //**************************
    // Execution code goes here  //**************************
    ...

Back to top

Add Logger code - optional

In the <Activity Name>.cs file, add information for the log using the LogInfo, LogDebug, or LogError statements. For example:

protected override STExecutionResult ExecuteStep()
{
try
{   
    LogInfo("Log Message 1");
    LogDebug("Log Message 2");
    LogError("Log Message 3");
...

Back to top

Add a Report statement - optional

In the <Activity Name>.cs file, add a Report statement. For example:

protected override STExecutionResult ExecuteStep()
{
try
{   
        DetailsReport = DetailsReport.Replace("\\n", "<BR>");
        this.Report("Message", DetailsReport);    ;
...

Back to top

Compile the project into a DLL

In your IDE, build the project and make sure the current <Activity Name> .dll file is in the new activity folder that you specified in the wizard.

Back to top

Deploy the activity in UFT

  1. In the final wizard screen, click Deploy in UFT.

  2. Click Finish to close the wizard and restart UFT.

Back to top