Manually create a custom Activity in C#

Relevant for: API testing only

This task describes how to create a new activity and implement it into UFT One.

To run a test with the custom activity on another machine, you need to copy all of the custom files to its <Installation_Folder>\addins\CustomerAddins\<addin_name> folder.

Prerequisite - create a runtime file

Create a C# project that implements your activity's actions in the addins\CustomerAddins\<addin_name> folder. For task details, see Create a runtime file.

Back to top

Create a signature file

  1. Create a new signature file with an .xml extension. in the addins\CustomerAddins\<addin_name> folder, together with the runtime file. Use the sample project in the <installation folder>\ExtensibilitySamples folder as a basis for your custom signature file.
  2. Customize the Resource section or copy the code provided below, modifying the bolded text for your needs.
  3. <Resource
      type="Activity"
      id="ReportMessageActivitySample"
      version="1.0.0"
      group="Miscellaneous"
      shortName="ReportMessageActivitySample"
      description="ReportMessageActivitySample allows you to send a custom message to the report and/or log. "
      assembly="ReportMessageActivitySample.dll"
      className="ReportMessageActivitySample.ReportMessageActivitySample"
      image="toolbox_ReportMessageActivitySample.png"
      visible="true"
      xmlns="http://hp.st.schemas/signature/v1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://hp.st.schemas/signature/v1.0 ../../../dat/schemas/Signature.xsd"
      >
  4. Add the required sections, such as GeneralProperties, InputProperties, Tabs, or Events.

  5. Add properties to the relevant sections.

    • GeneralProperties. Properties displayed in the Properties pane's General tab. In most cases you can use the section as it appears in the sample file, without any modifications. By default, it will provide the Step ID and Name properties.

    • InputProperties. Properties displayed in the Properties pane's Input/Checkpoints tab, in the Input pane.

    • OutputProperties. Properties displayed in the Properties pane's Input/Checkpoints tab, in the Checkpoints pane.

  6. Specify any external resource files.

  7. Close the file with the </Resource> tag.

  8. For more details about the structure of the signature file, see Signature files.

    Back to top

Create an addin file

  1. Create a new file with an .addin extension in the <installation directory>\addins\CustomerAddins\<addin_name> folder, together with the signature file.

  2. Use the sample addin file in the <installation folder>\ExtensibilitySamples folder as a basis, or copy the code provided below, modifying the bolded text for your needs.

    <?xml version="1.0" encoding="utf-8"?>
    <AddIn name        = "Report Message Activity Sample"
           author      = "John Doe"
           copyright   = "prj:///doc/copyright.txt"
           description = "Extensibility Sample - Report Message Activity"
             version="1.0">
    <Manifest>
        <!--<Must be unique -->
        <Identity name = "ReportMessageActivitySample"/>
      </Manifest>
      <Runtime>
        <Import assembly=":HP.ST.Fwk.DesignerModel"/>
      </Runtime>
      <Path name = "/ST/Activities">
        <!--Misc Activities -->
        <Activity id    = "ReportMessageActivitySample"
        displayName   = "ReportMessageSample"
         signatureFile = "ReportMessageActivitySample.xml"
        assembly="ReportMessageActivitySample.dll"/>
      </Path>  
    </AddIn>
  3. Create a unique Addin file for each activity—do not define multiple activities in a single Addin file.

  4. Define post-build tasks such as resgen.

  5. Compile the project and copy the DLL to the <installation_Folder>\addins\CustomerAddins\<addin_name> folder.

  6. For additional details, see Runtime files.

    Back to top

Provide a graphic for your activity - optional

  1. Copy an icon image for your activity into the <Installation_Folder>\addins\CustomerAddins\<addin_name> folder. This file should meet the following requirements:

    • a .png extension

    • sized at 16 x 16 pixels

    • 8-bit color depth

  2. Specify the name of the image file in the signature file's Resource Element.

Back to top

Check the implementation

  1. Reopen the application and drag the new activity into the Test Flow. Verify that the activity and its properties appear as expected.

  2. Provide property values.

  3. Run the test and observe the Output log and the run results.

  4. Enable checkpoints to verify the results and rerun the test.

Back to top