The manual testing functionality is deprecated. Do not use it for creating new tests. It will be removed in a future TestComplete release. |
To create manual tests, you typically use the Manual Test editor where you can create test steps and write descriptions and instructions for each step. However, you can also create manual tests from scripts.
Use the special ManualTestBuilder
object to support importing of these tests. This object includes methods and properties that let you specify the test name, create substeps, specify substeps’ properties and save changes. The general procedure includes the following steps:
- Use the functionality provided by the
ManualTestBuilder
object to create a new test, add steps and substeps and specify their properties (see below). - Call the
ManualTestBuilder.Save
method to store the created test to a file. The resultant file’s format will correspond to the Manual Test project item’s file. - Open your TestComplete project and add a new project item from the file. For more information on this, see Adding and Removing Project Items and Their Child Elements.
To create a manual test and test steps, perform the following actions:
-
Use the
ManualTestBuilder.Name
property to specify the test’s name. This name will identify the project item in the Project Explorer panel. -
The manual test always contains the root step. You can gain scripting access to it through the
ManualTestBuilder.Root
property. This property returns theManualTestStep
object that is used to work with steps from scripts. Using the object’s properties you can specify the desired properties of the step, for instance:-
Identifier (by default, TestComplete generates identifiers for each step, but you can change it any time later using the
Id
property of theManualTestStep
object). -
Caption (the step’s caption is displayed in the Step caption box and in the steps tree of the Manual Test editor).
-
Step description and notes.
-
File name of the step icon.
-
Format of the file holding the step instructions (HTML or XML+XSL).
-
Step instructions text or file holding the step instructions.
You can also specify whether the step will be executed during the test run or not.
-
-
To create a substep, call the
ManualTestBuilder.Root.AddSubstep
method. It will create a new substep and return theManualTestStep
object that corresponds to the created step. -
Use properties of this object to specify step properties. Call the
AddSubstep
method to create substeps. -
After you created the desired step hierarchy, call the
ManualTestBuilder.Save
method to save the created test to a file. Then you can add a project item from this file to the desired TestComplete project.
The following code demonstrates how you can create a manual test and its steps through a script and save the created test to a file:
JavaScript, JScript
function CreateManualTest()
{
var RootStep, TestStep;
// Clears the test properties
ManualTestBuilder.Reset();
// Specifies the test name.
// This name will identify the test to users in the Project Explorer panel
ManualTestBuilder.Name = "MyManualTestItem";
// Obtains the root step of the test.
// This step corresponds to the topmost node in the Manual Testing editor
RootStep = ManualTestBuilder.Root;
// Specifies the step caption
RootStep.Caption = "Root step of my item";
// Specifies the step ID. By default, TestComplete generates a unique string as id.
// However, you can change it any time at your desire.
RootStep.Id = "RootStep";
// Specifies the format of the file storing step instructions
// In our case, the format is HTML.
RootStep.IsXMLContent = false;
// Specifies the step instructions
RootStep.InstructionsText = "Welcome to Manual Testing."+"\r\n"+
"To start testing, press 'Begin Test'."+"\r\n"+
"To cancel testing, press 'Cancel'.";
// Adds a new substep
TestStep = RootStep.AddSubstep();
// Specifies the step caption
TestStep.Caption = "Step 1";
// Specifies the step id.
TestStep.Id = "Step_1_NewId";
// Specifies whether the step will be executed during the test run
// By default, Enabled is True. We included this line just to show
// how to enable or disable test steps.
TestStep.Enabled = true;
// Specifies the format of the file storing step instructions
// In our case, the format is HTML
TestStep.IsXMLContent = false;
// Specifies the name of the file storing step instructions
TestStep.InstructionsURL = "C:\\Tests\\Step1.htm";
// Adds a new substep to the root step and specifies its properties
TestStep = RootStep.AddSubstep();
TestStep.Caption = "Step 2";
TestStep.Id = "Step_2_NewId";
TestStep.Enabled = true;
TestStep.IsXMLContent = false;
TestStep.InstructionsURL = "C:\\Tests\\Step2.htm";
// Adds a substep to the second step and specifies its properties
TestStep = TestStep.AddSubstep();
TestStep.Caption = "Step 2 - Sub step 1";
TestStep.Id = "Step_2_1_NewId";
TestStep.Enabled = true;
TestStep.IsXMLContent = false;
TestStep.InstructionsURL = "C:\\Tests\\Step2_1.htm";
// Saves the created test to a file
ManualTestBuilder.Save("C:\\Work\\", true);
}
Python
def CreateManualTest():
# Clears the test properties
ManualTestBuilder.Reset();
# Specifies the test name.
# This name will identify the test to users in the Project Explorer panel
ManualTestBuilder.Name = "MyManualTestItem";
# Obtains the root step of the test.
# This step corresponds to the topmost node in the Manual Testing editor
RootStep = ManualTestBuilder.Root;
# Specifies the step caption
RootStep.Caption = "Root step of my item";
# Specifies the step ID. By default, TestComplete generates a unique string as id.
# However, you can change it any time at your desire.
RootStep.Id = "RootStep"
# Specifies the format of the file storing step instructions
# In our case, the format is HTML.
RootStep.IsXMLContent = False
# Specifies the step instructions
RootStep.InstructionsText = "Welcome to Manual Testing."+"\r\n"+ \
"To start testing, press 'Begin Test'."+"\r\n"+ \
"To cancel testing, press 'Cancel'."
# Adds a new substep
TestStep = RootStep.AddSubstep()
# Specifies the step caption
TestStep.Caption = "Step 1"
# Specifies the step id.
TestStep.Id = "Step_1_NewId"
# Specifies whether the step will be executed during the test run
# By default, Enabled is True. We included this line just to show
# how to enable or disable test steps.
TestStep.Enabled = True
# Specifies the format of the file storing step instructions
# In our case, the format is HTML
TestStep.IsXMLContent = False
# Specifies the name of the file storing step instructions
TestStep.InstructionsURL = "C:\\Tests\\Step1.htm"
# Adds a new substep to the root step and specifies its properties
TestStep = RootStep.AddSubstep()
TestStep.Caption = "Step 2"
TestStep.Id = "Step_2_NewId"
TestStep.Enabled = True
TestStep.IsXMLContent = False
TestStep.InstructionsURL = "C:\\Tests\\Step2.htm"
# Adds a substep to the second step and specifies its properties
TestStep = TestStep.AddSubstep()
TestStep.Caption = "Step 2 - Sub step 1"
TestStep.Id = "Step_2_1_NewId"
TestStep.Enabled = True
TestStep.IsXMLContent = False
TestStep.InstructionsURL = "C:\\Tests\\Step2_1.htm"
# Saves the created test to a file
ManualTestBuilder.Save("C:\\Work\\", True)
VBScript
Sub CreateManualTest
' Clears the test properties
ManualTestBuilder.Reset
' Specifies the test name.
' This name will identify the test to users in the Project Explorer panel
ManualTestBuilder.Name = "MyManualTestItem"
' Obtains the root step of the test.
' This step corresponds to the topmost node in the Manual Testing editor
Set RootStep = ManualTestBuilder.Root
' Specifies the step caption
RootStep.Caption = "Root step of my item"
' Specifies the step ID. By default, TestComplete generates a unique string as id.
' However, you can change it any time at your desire.
RootStep.Id = "RootStep"
' Specifies the format of the file storing step instructions
' In our case, the format is HTML.
RootStep.IsXMLContent = False
' Specifies the step instructions
RootStep.InstructionsText = "Welcome to Manual Testing." & vbNewLine &_
"To start testing, press 'Begin Test'." & vbNewLine &_
"To cancel testing, press 'Cancel'."
' Adds a new substep
Set TestStep = RootStep.AddSubstep
' Specifies the step caption
TestStep.Caption = "Step 1"
' Specifies the step id.
TestStep.Id = "Step_1_NewId"
' Specifies whether the step will be executed during the test run
' By default, Enabled is True. We included this line just to show
' how to enable or disable test steps.
TestStep.Enabled = True
' Specifies the format of the file storing step instructions
' In our case, the format is HTML
TestStep.IsXMLContent = False
' Specifies the name of the file storing step instructions
TestStep.InstructionsURL = "C:\Tests\Step1.htm"
' Adds a new substep to the root step and specifies its properties
Set TestStep = RootStep.AddSubstep
TestStep.Caption = "Step 2"
TestStep.Id = "Step_2_NewId"
TestStep.Enabled = True
TestStep.IsXMLContent = False
TestStep.InstructionsURL = "C:\Tests\Step2.htm"
' Adds a substep to the second step and specifies its properties
Set TestStep = TestStep.AddSubstep
TestStep.Caption = "Step 2 - Sub step 1"
TestStep.Id = "Step_2_1_NewId"
TestStep.Enabled = True
TestStep.IsXMLContent = False
TestStep.InstructionsURL = "C:\Tests\Step2_1.htm"
' Saves the created test to a file
Call ManualTestBuilder.Save("C:\Work\", True)
End Sub
DelphiScript
procedure CreateManualTest();
var
RootStep, TestStep : OleVariant;
begin
// Clears the test properties
ManualTestBuilder.Reset();
// Specifies the test name.
// This name will identify the test to users in the Project Explorer panel
ManualTestBuilder.Name := 'MyManualTestItem';
// Obtains the root step of the test.
// This step corresponds to the topmost node in the Manual Testing editor
RootStep := ManualTestBuilder.Root;
// Specifies the step caption
RootStep.Caption := 'Root step of my item';
// Specifies the step ID. By default, TestComplete generates a unique string as id.
// However, you can change it any time at your desire.
RootStep.Id := 'RootStep';
// Specifies the format of the file storing step instructions
// In our case, the format is HTML.
RootStep.IsXMLContent := False;
// Specifies the step instructions
RootStep.InstructionsText := 'Welcome to Manual Testing.' + #13#10 +
'To start testing, press "Begin Test".' + #13#10 +
'To cancel testing, press "Cancel".';
// Adds a new substep
TestStep := RootStep.AddSubstep();
// Specifies the step caption
TestStep.Caption := 'Step 1';
// Specifies the step id.
TestStep.Id := 'Step_1_NewId';
// Specifies whether the step will be executed during the test run
// By default, Enabled is True. We included this line just to show
// how to enable or disable test steps.
TestStep.Enabled := True;
// Specifies the format of the file storing step instructions
// In our case, the format is HTML
TestStep.IsXMLContent := False;
// Specifies the name of the file storing step instructions
TestStep.InstructionsURL := 'C:\Tests\Step1.htm';
// Adds a new substep to the root step and specifies its properties
TestStep := RootStep.AddSubstep();
TestStep.Caption := 'Step 2';
TestStep.Id := 'Step_2_NewId';
TestStep.Enabled := True;
TestStep.IsXMLContent := False;
TestStep.InstructionsURL := 'C:\Tests\Step2.htm';
// Adds a substep to the second step and specifies its properties
TestStep := TestStep.AddSubstep();
TestStep.Caption := 'Step 2 - Sub step 1';
TestStep.Id := 'Step_2_1_NewId';
TestStep.Enabled := True;
TestStep.IsXMLContent := False;
TestStep.InstructionsURL := 'C:\Tests\Step2_1.htm';
// Saves the created test to a file
ManualTestBuilder.Save('C:\Work\', True);
end;
C++Script, C#Script
function CreateManualTest()
{
var RootStep, TestStep;
// Clears the test properties
ManualTestBuilder["Reset"]();
// Specifies the test name.
// This name will identify the test to users in the Project Explorer panel
ManualTestBuilder["Name"] = "MyManualTestItem";
// Obtains the root step of the test.
// This step corresponds to the topmost node in the Manual Testing editor
RootStep = ManualTestBuilder["Root"];
// Specifies the step caption
RootStep["Caption"] = "Root step of my item";
// Specifies the step ID. By default, TestComplete generates a unique string as id.
// However, you can change it any time at your desire.
RootStep["Id"] = "RootStep";
// Specifies the format of the file storing step instructions
// In our case, the format is HTML.
RootStep["IsXMLContent"] = false;
// Specifies the step instructions
RootStep["InstructionsText"] = "Welcome to Manual Testing."+"\r\n"+
"To start testing, press 'Begin Test'."+"\r\n"+
"To cancel testing, press 'Cancel'.";
// Adds a new substep
TestStep = RootStep["AddSubstep"]();
// Specifies the step caption
TestStep["Caption"] = "Step 1";
// Specifies the step id.
TestStep["Id"] = "Step_1_NewId";
// Specifies whether the step will be executed during the test run
// By default, Enabled is True. We included this line just to show
// how to enable or disable test steps.
TestStep["Enabled"] = true;
// Specifies the format of the file storing step instructions
// In our case, the format is HTML
TestStep["IsXMLContent"] = false;
// Specifies the name of the file storing step instructions
TestStep["InstructionsURL"] = "C:\\Tests\\Step1.htm";
// Adds a new substep to the root step and specifies its properties
TestStep = RootStep["AddSubstep"]();
TestStep["Caption"] = "Step 2";
TestStep["Id"] = "Step_2_NewId";
TestStep["Enabled"] = true;
TestStep["IsXMLContent"] = false;
TestStep["InstructionsURL"] = "C:\\Tests\\Step2.htm";
// Adds a substep to the second step and specifies its properties
TestStep = TestStep["AddSubstep"]();
TestStep["Caption"] = "Step 2 - Sub step 1";
TestStep["Id"] = "Step_2_1_NewId";
TestStep["Enabled"] = true;
TestStep["IsXMLContent"] = false;
TestStep["InstructionsURL"] = "C:\\Tests\\Step2_1.htm";
// Saves the created test to a file
ManualTestBuilder["Save"]("C:\\Work\\", true);
}
Note: | You can also create a manual test in your keyword test. Write some script routine, like the one described above, and call it from your keyword test using the Run Script Routine operation. |