When I started this blog, I said I will show how to use QTP to test a website, and how to use TestPartner (TP) to test a windows application. I also said the main focus will be QTP instead of TP, since there is place to download QTP for free but no place to download TP, and you will have access to the website but won’t have access to the windows application.
However, beside a few posts (post#4, post#5, post#6)about how to test the login function of the website by QTP, most of my posts (until now) are about TP and testing an image processing work station. Today, I decided to end the testing of the work station, and from tomorrow, I will switch back to use QTP to test the website.
I want to give a summary of the test architecture I designed for the workstation test before I move on to test the website:
The object and scope of the test is to test all the pre-defined measurements and annotations in the image processing workstation.
Compare to measurements, annotations are much easier, so I will only explain how to test the measurements, and you can adopt similar methods to test the annotations.
In the workstation, we organize pre-defined measurements in 3 layers. The top layer are 5 measurement packages, and under each package, there are 1-20 protocols, which is the second layer. Each protocol, includes 5-20 measurements, which is the bottom layer. There are about 1000 measurements in total.
All these 1000 measurements can be divided into 10 different categories, for example, there are linear measurements, area measurements, velocity measurements, and so on. They way to draw measurements from different categories are not the same, for example, linear measurement needs 2 clicks in the image area and area measurement needs 3 clicks.
Measurements under same protocol/package apply to different modes, for example, protocol A has measurement 1, 2, 3, …, 10. Measurement 1, 3, 7 apply to B-Mode, and the rest apply to M-Mode.
Since the workstation software is one of the product from my current company, we have acquired images during manual testing, and these images can be reused for automation testing too. These images are arranged in 3 layers too in order to cope with the 3 layers of the measurements. The top layer of the images is called study, which is named by package name, i.e., each package has 1 study, so there are 5 studies in total. Under each study, there are a few series, and each series is named by protocol name, so if there are 10 protocols in this package, then there will be 10 series in this study. Under each series, there are many images from different modes, and there won’t be any images from the same mode under 1 series. If the measurements under a protocol apply to 5 different modes, then there will be 5 images each from a different mode listed under the series.
As a summary, the data/images look like this:
- Study A (named with Package A name) (expanded)
- Series 1 (named with Protocol 1 name) (expanded)
- image (B-Mode)
- image (M-Mode)
- image (other mode)
- Series 2 (named with Protocol 2 name) (indented)
- Series 3 (named with Protocol 3 name) (indented)
- Study B (named with Package B name) (indented)
- Study C (named with Package C name) (indented)
- Study D (named with Package D name) (indented)
- Study E (named with Package E name) (indented)
We also developed manual test cases for these packages. The documents contains these test cases are called system validation procedures (SVP). Each SVP covers 1 measurement package, so there are 5 SVPs. In each SVP, test cases are divided into different sections, and each section is for one protocol. In each section, there are sub-sections divided by modes. For example, in the SVP for package A, in section1 which is for protocol 1, there is a few sub-sections. One of the sub-section is to load a B-Mode image, and under this sub-section, there are many test cases to draw measurements, i.e., each test case will ask you to draw one of the measurement within the protocol.
We created the test cases in this way to make it easy for manual testers to execute the test cases, but it is not the right approach to develop automation test script, since there are about 1000 manual test cases to draw measurements, and we should not develop 1000 automation test scripts accordingly.
The way I want to write the scripts is to use an excel sheet as input, i.e., all the measurements are listed in the excel sheet, and they are stored in the following way:
Package A
Protocol 1
B-Mode
Measurement a Category a Unit a Link a
Measurement b Category b Unit b Link b
…
I will also concentrate all the repetitive test cases into one test case, so there will be in total about 10 test scripts:
test script 1: test all the packages are enabled in the preference – measurement panel; (post#10)
test script 2: test all the protocols are enabled in the preference – measurement panel; (post#12)
test script 3: test all the measurements are enabled in the preference – measurement panel; (post#14)
test script 4: draw all the measurements and output the measurements’ labels to excel sheet a; (this post#20)
test script 5: output all the measurements’ value from measurement panel to excel sheet b;
test script 6: output all the measurements’ value from analysis browser to excel sheet c;
test script 7: output all the measurements’ value to csv;
test script 8: rearrange the data in excel sheet a, b, c, and csv and compare the values are the same;
test script 9: use data from excel csv and measurement template (created during manual testing, an excel sheet has build in formulas) to check calculations results;
test script 10: draw all the annotations and out put the annotations’ label to excel sheet d, and check the values.
In the workstation, there are many objects, but they are no more than 4 types, i.e., Treeview, Listview, ImageView, and buttons. We talked about Treeview in post#10, #12, and #14, Listview in post#19, and ImageView in this post#20. Above mentioned scripts 5 to 10 are just reuse of the properties and methods of these objects, plus some logic (such as loops), so I don’t think there is need for me to post the scripts for them here (anyway you won’t have access to the workstation to understand my scripts).
Below is the script for above mentioned “test script 4″. Sub_MakeMeasurement is a test script, and inside Sub_MakeMeasurement, Function_MakeMeasurement is called, which is a module. For ImageView, there is one thing you need to know, that is how to capture the text on the ImageView: ImageView.CaptureText (startX, startY, width, depth)
Sub_MakeMeasurement
'Testing condition: If last "Link" column of the "ModeCategoryUnit" sheet is empty, then add a space in a cell of the column.
'$TPinclude "Declaration_GlobalConstants"
'$TPinclude "Function_MakeMeasurement"
Sub Main()
'Import data from Measurement.xlsx's ModeCategoryUnit sheet to array InputData()
Dim RowCount As Integer
Dim ColumnCount As Integer
Dim InputData() As String 'Dynamic array
Dim OutputData() As String 'Dynamic array
RowCount = Function_ExcelSheetRowCount.ExcelSheetRowCount(ExcelFilePath_Measurement, "ModeCategoryUnit")
ColumnCount = Function_ExcelSheetColumnCount.ExcelSheetColumnCount(ExcelFilePath_Measurement, "ModeCategoryUnit")
ReDim InputData(1 To RowCount, 1 To ColumnCount) As String 'Array is sized dynamically
ReDim OutputData(1 To RowCount, 1 To ColumnCount) As String 'Array is sized dynamically
InputData() = Function_GetExcelSheetData.GetExcelSheetData(ExcelFilePath_Measurement, "ModeCategoryUnit")
'From Study Browser, open Images from different Study and Series
Dim Study_Package As String 'Study names are the Package names
Dim Series_Protocol As String 'Series names are the Protocol names
Dim Image_Mode As String 'Image names are the Mode names
Dim j As Integer
Dim Count As Integer
'Open the workstation
ProgramManagerWindow("Application=EXPLORER.EXE Caption='Program Manager'").Attach
ListView("Index=1").Select "the workstation", tpMouseDoubleClick
'Attach to the workstation
Window("the workstation").Attach
For j = 1 To ColumnCount Step 4
'Inside Study Browser, load the Image_Mode from the correct Study and Series
Study_Package = InputData(1, j)
Series_Protocol = InputData(2, j)
Image_Mode = InputData(3, j)
OutputData(1, j) = InputData(1, j)
OutputData(2, j) = InputData(2, j)
OutputData(3, j) = InputData(3, j)
'If can not find the Series_Protocol, then the Study_Package needs to be expanded
If ListView("Parent.Caption='Study Browser'").FindItem(Series_Protocol) = 0 Then
ListView("Parent.Caption='Study Browser'").Select (Study_Package), tpMouseDoubleClick
End If
'If the mode column (i.e., the 6th column) of the row after Series_Protocol is empty
'then the row is either a Series or a Study
'the Series_Protocol needs to be expanded to see all the Image_Modes
Count = ListView("Parent.Caption='Study Browser'").FindItem(Series_Protocol)
If ListView("Parent.Caption='Study Browser'").GetItem(Count + 1, 6) = "" Then
ListView("Parent.Caption='Study Browser'").Select (Series_Protocol), tpMouseDoubleClick
End If
'Search to load the Image_Mode in between the Series_Protocol and next Series/Study
Do While ListView("Parent.Caption='Study Browser'").GetItem(Count + 1, 6) <> ""
If ListView("Parent.Caption='Study Browser'").GetItem(Count + 1, 6) = Image_Mode Then
ListView("Parent.Caption='Study Browser'").SelectIndex (Count + 1), tpMouseDoubleClick
Exit Do
Else
Count = Count + 1
End If
Loop
'Inside the Mode Window, stop playback, then delete existing measurements and make new measurements
Button("Caption=Forw").Click 'Stop PlayBack
Button("Caption=Home").Click 'Display the first Frame
Button("Caption=Msmnt").Click 'Open Measurement panel
'Delete measurements
'Do while the measurement side panel is not empty ("#NameValue" is the header of the ListView)
Do While ListView("Label='Measured Values'").CaptureText <> "#NameValue"
ListView("Label='Measured Values'").SelectIndex 1 'Select the top item to delete
ListView("Label='Measured Values'").Type "{ExtDelete}" 'Press [Delete] key
Loop
'Draw new measurements
'Select Measurement Pacakge
ComboBox("Parent.Caption=ModeRootView").Select Study_Package
Dim Measurement As String
Dim Category As String
Dim i As Integer
For i = 4 To RowCount
If InputData(i, j) <> "" And InputData(i, j) <> "(Note 1)" And InputData(i, j) <> "(Note1)" Then
If InputData(i, j + 1) <> "" Then
Measurement = InputData(i, j)
Category = InputData(i, j + 1)
OutputData(i, j) = InputData(i, j)
OutputData(i, j + 1) = InputData(i, j + 1)
OutputData(i, j + 2) = InputData(i, j + 2)
Else
Measurement = InputData(i, j)
Category = InputData(i + 1, j + 1)
OutputData(i, j) = InputData(i, j)
End If
'Call Function_MakeMeasurement to draw the measurement
Dim Label As String
Label = Function_MakeMeasurement.MakeMeasurement(Image_Mode, Series_Protocol, Measurement, Category)
OutputData(i, j + 3) = Label
ElseIf InputData(i, j) <> "" And InputData(i, j) = "(Note 1)" Then
OutputData(i, j) = InputData(i, j)
OutputData(i, j + 1) = InputData(i, j + 1)
OutputData(i, j + 2) = InputData(i, j + 2)
ElseIf InputData(i, j) <> "" And InputData(i, j) = "(Note1)" Then
OutputData(i, j) = InputData(i, j)
OutputData(i, j + 1) = InputData(i, j + 1)
OutputData(i, j + 2) = InputData(i, j + 2)
Else: Exit For
End If
Next
'Switch back to Study Browser
Button("Caption=B").Click
Next
'Close application to reset its original state
Window.Close
'Use shared module "Function_SaveArrayAsExcelSheet" to write data from array OutputData() to Excel
a = Function_SaveArrayAsExcelSheet.SaveArrayAsExcelSheet(OutputData, RowCount, ColumnCount, ExcelFilePath_Measurement, "ImageArea")
'Erase arrays
Erase InputData
Erase OutputData
End Sub
Function_MakeMeasurement
Function MakeMeasurement(Mode As String, Protocol As String, Measurement As String, Category As String)
'Go to an empty frame/section of the loop
script not posted
'Select \Protocol\Measurement
TreeView("Parent.Caption=ModeRootView").SelectItem "\" & Protocol & "\" & Measurement
'Draw the measurement
Dim MeasurementLabel As String
script not posted
'MakeMeasurement Function returns MeasurementLabel
MakeMeasurement = MeasurementLabel
End Function