Importing Manual Test Instructions Into TestComplete

 Since TestComplete 10.40, the Manual Testing functionality is deprecated. We do not recommend using it when creating new tests.

Author: SmartBear Software
Applies to: TestComplete 10.30 and earlier.

Introduction

A manual test is a description of test steps that a tester performs on the tested application manually. Manual testing is usually performed when a test is too difficult or impossible to automate, for example, when you want to test for user interface details or behavior. Manual testing is the best choice when the steps of the test must be completed by a test engineer, not by an automated test script.

TestComplete can use manual tests as part of its automated tests. It lets you create and manage manual tests when testing applications and perform manual testing over your application.

Typically, you create manual tests in TestComplete using the Manual Test editor:

Manual Test Editor

The editor allows you to create a collection of steps to be performed when the application is being tested, with a description of and detailed instructions for each step. During manual testing the dialog describing the current step is shown on the screen:

Step Description Dialog

This dialog holds information on the step being performed while manual testing. It lets you stop manual testing or indicate whether the step was accomplished successfully or whether it failed.

If you had not used an automated testing tool before, you may need to import manual tests into TestComplete. It will allow you to perform these manual tests along the other automated tests. Usually, a manual test is stored in a file that lists the steps. For example, you can store manual testing instructions in a Microsoft Word document, an Access database, an Excel sheet, or other tools. The goal of the import is to transfer manual test steps from these files to TestComplete.

There are two ways to import manual test instructions into your TestComplete projects:

  • Using the Import Test Wizard.
  • Using special program objects.

Using the Import Test Wizard

TestComplete provides specific features that help you import manual test instructions from Microsoft Word, Excel and text files into your projects. It recognizes test steps within these files and creates a manual test project item with the same step hierarchy in your project. When importing test instructions, TestComplete creates the root step and sub-steps, specifies their captions and instructions, saves the test to a .tcMT file and then automatically adds it to the current project.

In order for TestComplete to recognize the step hierarchy correctly, it is recommended that you use some fixed structures and types of formatting in your files. So, before importing manual tests to TestComplete, you should adjust your instructions according to the established structures. You can find recommended structure formats for different file types in the Format Recommendations for Manual Test Instructions topic in TestComplete documentation.

After you prepare the file with test instructions, you can import it to your project. To do this:

  • Open your TestComplete project where the manual test should be created.
  • Select File | Import | Test from TestComplete’s main menu.

Import Test Command

This will call the Import Test Wizard.

In the wizard:
  • Enter the name of the manual test item to be created to the Test Name edit box.
  • In the Source File Name edit box, specify the fully qualified name of the file containing the manual test instructions. You can either type the file name or click the ellipsis button and choose the needed file using the standard Open File dialog. Click Next.

Import Test Wizard

  • Wait until TestComplete finishes importing and click Finish to create the manual test item. Cancel will close the dialog without performing any actions.

After the manual test is created, it will be shown in the Project Explorer under the ManualTests node.

Note that the manual test importing tool creates one Manual Test project item that corresponds to one source file. If your document contains instructions for several manual tests, it is recommended to divide the source document into several documents that will contain instructions for individual manual tests and then import instructions from these documents to TestComplete separately.

Project Explorer

To view or modify the created test in the Manual Test editor, double-click the test node in Project Explorer. Using the editor, you can add or delete test steps to or from the created manual test, rename steps, change their description, and perform other actions.

Importing Manual Test Instructions Using Program Objects

TestComplete provides the ManualTestBuilder program object that allows you to import manual tests into TestComplete. This object includes methods and properties that let you create the manual test file. Later you can add this file to any TestComplete project.

The general procedure of creating the manual test includes the following steps: specifying the manual test name, creating substeps, specifying substeps’ properties and saving changes. To perform these steps, use methods and properties of the ManualTestBuilder object.

  1. To specify the manual test’s name, use the ManualTestBuilder.Name property. The name will identify the project item in the Project Explorer panel.
  2. The manual test must contain the root step. To create the root step, use the ManualTestBuilder.Rootproperty. This property returns the ManualTestStepobject that is used to work with steps from the manual tests.
  3. Using the ManualTestStepobject’s properties, specify the desired properties of the root 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 the ManualTestStep object).
    • Caption (you can specify the step’s caption that is displayed in the Step caption box and in the steps tree of the Manual Test editor using the Caption property).
    • Step description and notes.
    • File name of the step icon.
    • Using the InstructionsText or InstructionsURL properties, you can specify step instructions text or file holding the step instructions.
    • Using the IsXMLContent property, you can specify the format of the file holding the step instructions (HTML or XML+XSL).
  4. To create a substep, call the ManualTestBuilder.Root.AddSubstep method. It will create a new substep and return the ManualTestStep object that corresponds to the created step.
  5. Using the object’s properties, specify the substep properties.
  6. Repeat steps 4-5 to create the desired step hierarchy.
  7. To store the created manual test to a .tcMT file, call the ManualTestBuilder.Save method. Using the FilePath parameter of this method, you specify the folder where the created file will be saved.

Thus, using the functionality provided by the ManualTestBuilder object, you can create manual tests from scripts or keyword tests (keyword-driven testing).

Suppose we have a Microsoft Word document that contains a manual test instruction. The following example demonstrates how to create a manual test by importing test instruction from this .doc file. Note that this sample code is written in the VBScript language.

'[VBScript]
 
Dim WordApp

Dim TestFileName 
Dim OutputDir 

const wdFormatFilteredHTML = 10

Sub Main
 Dim StepCount 
 
   ' Obtain the file that contains the manual test instruction and the folder where the created test and temporary .htm 
   files will be stored
 TestFileName=Project.Path + "..\manual_test_sample.doc"
 OutputDir=Project.Path + "..\OutputDir\"
 
   ' Create the output folder
 Call aqFileSystem.CreateFolder(OutputDir)
 
   ' Check whether the test file and output folder exist in the system
 If not aqFileSystem.Exists(TestFileName) Then
     Log.Warning(" Test file doesn't exists ")
     Exit Sub 
 End If
 If not aqFileSystem.Exists(OutputDir) Then
     Log.Warning(" Output directory doesn't exists ")
     Exit Sub
 End If
 
   ' Connect to Microsoft Word
 Set WordApp = Sys.OleObject("Word.Application")
 WordApp.Visible = false
 
   ' Call the SplitDoc routine and assign the value to the StepCount variable
 StepCount = SplitDoc(TestFileName,OutputDir)
   ' Call the BuildTest routine that will create a .tcMT file using the .htm files
 BuildTest "Sample",OutputDir,StepCount
 
   ' Close Microsoft Word
 WordApp.Quit() 
 
 While Sys.WaitProcess("WINWORD", 1000).Exists  
   Call Sleep(500)
 Wend   
End Sub

 ' Copy the text enclosed within the Prev and Next lines from Source to Dest
Sub CopyAndPaste(Source,Dest,prev,pnext)
Dim StepRange
 Set StepRange=Source.Range(prev,pnext)
 StepRange.Select()
 Source.ActiveWindow.Selection.Copy()
 Dest.Select()
 Dest.ActiveWindow.Selection.Paste() 
End Sub

 ' Divide a .doc file into a number of .htm files and return the number of manual test steps
Function SplitDoc(TestFileName,OutputDir) 
 Dim MainDocument, TempDocument, Range, succ, i, prev, pnext

 i = 0 
   ' Open a test file and create a new .doc file
 Set MainDocument=WordApp.Documents.Open(TestFileName)
 Set TempDocument=WordApp.Documents.Add()
   ' Obtain the contents of the test file  
 Set Range=MainDocument.Content
 
   ' Create the RootStep.htm file
 prev=Range.Start
 succ=Range.Find.Execute("Step ")
 Range.Select()
 pnext=WordApp.Selection.Start
 
 If succ Then 
     ' Copy the root step description to the temporary .doc file  
   CopyAndPaste MainDocument,TempDocument,prev,pnext
     ' Save this temporary file to the RootStep.htm file 
   TempDocument.SaveAs OutputDir+"RootStep",wdFormatFilteredHTML
 End If
 
   ' Create more .htm files each contains description of a test step
 While succ
   succ=Range.Find.Execute("Step ")
   If succ Then 
     Range.Select()  
     prev=pnext
     pnext=MainDocument.ActiveWindow.Selection.Start
       ' The text enclosed within the Prev and Next lines is the description of the next step
     CopyAndPaste MainDocument,TempDocument,prev,pnext
     i=i+1
     TempDocument.SaveAs OutputDir+"Step"+aqConvert.IntToStr(i),wdFormatFilteredHTML 
    End If 
  Wend
 
 ' Create an .htm file that contains description of the last test step
prev=pnext
 pnext=MainDocument.Content.End
 CopyAndPaste MainDocument,TempDocument,prev,pnext
 i=i+1
 
 TempDocument.SaveAs OutputDir+"Step"+aqConvert.IntToStr(i),wdFormatFilteredHTML 
   ' Close the test file and temporary document
 TempDocument.Close()
 MainDocument.Close()
 
   ' Return the number of manual test steps              
 SplitDoc = i
End Function

 ' Create a tcMT file using the .htm files
Sub BuildTest(TestName,OutputDir,StepCount) 
Dim RootStep, TestStep, Document, i, Description, Caption
 
   ' Change the RootStep.htm file
 Set Document=WordApp.Documents.Open(OutputDir+"RootStep.htm")
 Caption=aqString.Trim(Document.Sentences(1).Text)
 Document.Sentences(1).Delete()
 Document.Close(true)
 
   ' Specify the description that will be displayed for the entire manual test while providing detailed instructions 
   on how to perform a step. Description="Follow the instructions listed below and choose the button that corresponds 
   to the result of your actions."

   ' Clear the test properties 
 ManualTestBuilder.Reset()
   ' Specify the test’s name 
 ManualTestBuilder.Name=TestName
   ' Gain scripting access to the root step
 Set RootStep=ManualTestBuilder.Root

   ' Specify the properties of the root step
 RootStep.Caption=Caption
 RootStep.Description=Caption
 RootStep.InstructionsURL=OutputDir+"RootStep.htm"
 RootStep.IsXMLContent=false
 RootStep.Enabled=true
 Log.Message("Step ''"+RootStep.Caption + "'' was added.")
 
   ' Change the other .htm files, create substeps and specify their properties
 For i=1 to StepCount 
   Set Document=WordApp.Documents.Open(OutputDir+"Step"+aqConvert.IntToStr(i)+".htm")
   Caption=aqString.Trim(Document.Sentences(2).Text)
   Document.Sentences(1).Delete()
   Document.Sentences(1).Delete()
   Document.Close(true)
 
   Set TestStep=RootStep.AddSubstep()
   TestStep.Caption=Caption
   TestStep.Description=Description 
   TestStep.InstructionsURL=OutputDir+"Step"+aqConvert.IntToStr(i)+".htm"
   TestStep.IsXMLContent=false
   TestStep.Enabled=true
   Log.Message("Step ''"+TestStep.Caption+"'' was added.")
 Next  

 ' Save the created test to a .tcMT file
ManualTestBuilder.Save OutputDir,false
Log.Message(OutputDir+TestName+".tcMT" + " was saved.") 
End Sub

The script performs the following actions:

  • Obtains the file that contains the manual test instruction and the folder where the test and temporary .htm files will be stored.
  • Connects to Microsoft Word via COM.
  • Opens the .doc file that contains a manual test instruction.
  • Divides the .doc file into a number of .htm files each will contain an instruction of a test step.
  • Using the ManualTestBuilder object and its properties, creates the manual test:
    • Clears the test’s properties.
    • Specifies the test’s name.
    • Creates the root step and specify its properties: step caption, description, file holding the step instruction, format of this file. The RootStep.htm file that was created earlier is used as file holding the step instruction.
      Using the Enable property we also specify that the step is included to the test run.
    • Adds substeps to the test and specify their properties like the properties of the root step were specified. The .htm files that were created earlier, except RootStep.htm, are used as files holding the substeps instructions.
  • Saves the created test to a .tcMT file.
  • Closes the Microsoft Word application.

The <TestComplete 10 Samples>\Common\Manual Testing\Create Manual Test Using .doc File folder includes the sample project that uses this script. The script works with the manual_test_sample.doc file, creates the Sample manual test file and saves it into the OutputDir folder.

After you have created the .tcMT file, you can add the manual test item to the desired TestComplete project. In order to do this, make sure that the Manual Tests project item is added to the project. By default, it is not added. To include this item in your project:

  • Right-click the project in the Project Explorer panel and choose Add | New Item from the context menu. This will call the Create Project Item dialog.

Create Project item Dialog

  • In the dialog, select the Manual Tests project item and press OK to save the changes.

The Manual Tests project item will appear under the project node in the Project Explorer.

Now you can add the manual test item to the project: right-click the Manual Tests project item in the Project Explorer, select Add | Existing Item from the context menu and use the ensuing Open File dialog to select the manual test file.

Note that adding a manual test item from a file does not create a copy of this item. TestComplete just adds an item reference to your project.

Conclusion

TestComplete allows you to create manual tests using the file that lists the test steps. It offers the special Import Test Wizard that allows you to easily and quickly import test instructions from Microsoft Word, Excel or text files to TestComplete project. The wizard recognizes your instructions itself and automatically adds the created manual test to the project.

Besides that, TestComplete provides a special program object whose methods and properties let you create manual tests using different external files: specify a test name, create sub-steps, specify sub-steps’ properties and save the test to a manual test file. In this article, we have explained how to use this object to import a test description from a Microsoft Word document. To see how to create a manual test from script by importing an instruction from an Access database, use the Create Manual Test Using .mdb File sample project from the <TestComplete 10 Samples>\Common\Manual Testing\Create Manual Test Using .mdb File folder.

The described functionality is available for all TestComplete modules you may use – Desktop, Web and Mobile.

If you are interested in using manual testing or automated testing with TestComplete, download and try it today.

More Information