Importing Manual Test Instructions Into TestComplete

Author: AutomatedQA Corp.
Last updated: April 14, 2009
Applied to: TestComplete 7

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. TestComplete includes a special program object that lets you do this.

Importing Manual Test Instructions

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.

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.Root property. This property returns the ManualTestStep object that is used to work with steps from the manual tests.
  3. Using the ManualTestStep object’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).

After you have created the test 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 to 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.

Importing Manual Tests From .doc Files

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.

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 7 Samples>\Scripts\CreateManualTest\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.

Conclusion

TestComplete allows you to create manual tests using the file that lists the test steps. It provides a special program object which methods and properties let you specify a test name, create substeps, specify substeps’ properties and save the test to a manual test file.

In this article, we have explained how 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 Samples>\Scripts\CreateManualTest\Create Manual Test Using .mdb File folder. If you are interested in using manual testing or automated testing with TestComplete, download and try it today.

 
© 2010 AutomatedQA Corp. All rights reserved.
Home | Privacy | Terms of Use | About | Contact Us | Site Map | Print