On this step, we will record a script that performs one test iteration. The script will launch the tested application, add a new order, check the order information generated by the application and close the application. During script recording, we will add comments to separate parts of the script performing different tasks.
Note: If you already have a script recorded or created from scratch that you want to modify to replace hard-coded values with values extracted from a data-source, go to the Retrieving Data from the Storage step.
Here are the detailed steps to record a test script:
-
Select Test > Record > Record Script from the TestComplete main menu.
-
Add the “Launching the Orders application” comment to the test:
-
Click Add Comment on the Recording toolbar. The Add Comment to Test dialog appears.
-
Enter “Launching the Orders application” and click Add.
-
-
Select the tested application from the Run App menu of the Recording toolbar.
-
Add the “Opening the Order form” comment to the test as described above.
-
Switch to the Orders application and select Orders > New order from the main menu. The Order form will appear.
-
Add the “Populating the Order form” comment to the test.
-
Specify the following values in the Order form:
Field Value Product Select FamilyAlbum. Quantity 20 Date 05/06/2005 Customer Name John Smith Jr Street 12, Orange Blvd City Grovetown, CA State US Zip 111155 Card Select MasterCard. Card No 555777555888 Expiration Date 05/06/2005 -
Add the “Creating checkpoints” comment to the test.
-
Create a checkpoint to verify the Price per unit value in the Order form:
-
Click on the Recording toolbar and make sure the Enable Quick Checkpoints check box is selected.
-
Move the mouse pointer to the Price per unit text box. TestComplete will highlight it with a red frame.
-
Stop moving the mouse pointer until the icon becomes opaque and move the pointer to the icon. TestComplete will show the Quick Checkpoints menu.
In the menu, click
wText = "$80"
:TestComplete will add a property checkpoint to your recorded test and will display a notification about it. The checkpoint will verify that the
wText
property of the Price per unit text box equals the specified text.
-
-
You can also create checkpoints for the
wText
property of the Discount and Total edit boxes in the same way. -
Add the “Closing the Order form” comment to the test.
-
Click OK in the Order form.
-
Add the “Closing the Orders application” comment to the test.
-
Close the Orders application. The Confirmation dialog box appears asking whether you want to save the changes.
-
Click No in the Confirmation dialog box.
-
Click Stop on the Recording toolbar.
The recorded script looks like this:
JavaScript, JScript
function Test1()
{
var orders;
var mainForm;
var orderForm;
var groupBox;
var numericUpDown;
var textBox;
// Launching the Orders application
TestedApps.RunAll();
// Opening the Order form
orders = Aliases.Orders;
mainForm = orders.MainForm;
mainForm.MainMenu.Click("Orders|New order...");
// Populating the Order form
orderForm = orders.OrderForm;
groupBox = orderForm.Group;
groupBox.ProductNames.ClickItem("FamilyAlbum");
numericUpDown = groupBox.Quantity;
numericUpDown.Click(8, 7);
numericUpDown.wValue = 20;
groupBox.Date.wDate = "5/6/2005";
textBox = groupBox.Customer;
textBox.Click(69, 12);
textBox.wText = "John Smith Jr";
textBox = groupBox.Street;
textBox.Click(4, 8);
textBox.wText = "12, Orange Blvd";
textBox = groupBox.City;
textBox.Click(12, 14);
textBox.wText = "Grovetown, CA";
textBox = groupBox.State;
textBox.Click(21, 6);
textBox.wText = "US";
textBox = groupBox.Zip;
textBox.Click(14, 14);
textBox.wText = "111155";
groupBox.MasterCard.ClickButton();
textBox = groupBox.CardNo;
textBox.Click(35, 15);
textBox.wText = "555777555888";
groupBox.ExpDate.wDate = "5/6/2005";
// Creating checkpoints
aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.Price, "wText", cmpEqual, "$80", false);
aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.Discount, "wText", cmpEqual, "15%", false);
aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.groupBox1.Total, "wText", cmpEqual, "1360", false);
// Closing the Order form
orderForm.ButtonOK.ClickButton();
// Closing the application
mainForm.Close();
orders.dlgConfirmation.btnNo.ClickButton();
}
Python
def Test1():
#Launching the tested application
TestedApps.RunAll()
#Opening the Order form
orders = Aliases.Orders
mainForm = orders.MainForm
mainForm.MainMenu.Click("Orders|New order...")
#Populating the Order form
orderForm = orders.OrderForm;
groupBox = orderForm.Group;
groupBox.ProductNames.ClickItem("FamilyAlbum")
numericUpDown = groupBox.Quantity
numericUpDown.Click(8, 7)
numericUpDown.wValue = 20
groupBox.Date.wDate = "5/6/2005"
textBox = groupBox.Customer
textBox.Click(69, 12)
textBox.settext("John Smith Jr")
textBox = groupBox.Street
textBox.Click(4, 8)
textBox.wText = "12, Orange Blvd"
textBox = groupBox.City
textBox.Click(12, 14)
textBox.wText = "Grovetown, CA"
textBox = groupBox.State
textBox.Click(21, 6)
textBox.wText = "US"
textBox = groupBox.Zip
textBox.Click(14, 14)
textBox.wText = "111155"
groupBox.MasterCard.ClickButton()
textBox = groupBox.CardNo
textBox.Click(35, 15)
textBox.wText = "555777555888"
groupBox.ExpDate.wDate = "5/6/2005"
#Creating checkpoints
aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.Price, "wText", cmpEqual, "$80")
aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.Discount, "wText", cmpEqual, "15%")
aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.groupBox1.Total, "wText", cmpEqual, "1360")
#Closing the Orders form
orderForm.ButtonOK.ClickButton()
#Closing the Orders application
mainForm.Close()
orders.dlgConfirmation.btnNo.ClickButton()
VBScript
Sub Test1
Dim orders
Dim mainForm
Dim orderForm
Dim groupBox
Dim numericUpDown
Dim textBox
' Launching the Orders application
TestedApps.RunAll
' Opening the Order form
Set orders = Aliases.Orders
Set mainForm = orders.MainForm
Call mainForm.MainMenu.Click("Orders|New order...")
' Populating the Order form
Set orderForm = orders.OrderForm
Set groupBox = orderForm.Group
Call groupBox.ProductNames.ClickItem("FamilyAlbum")
Set numericUpDown = groupBox.Quantity
Call numericUpDown.Click(37, 9)
numericUpDown.wValue = 20
groupBox.Date.wDate = "5/6/2005"
Set textBox = groupBox.Customer
Call textBox.Click(39, 7)
textBox.wText = "John Smith Jr"
Set textBox = groupBox.Street
Call textBox.Click(66, 7)
textBox.wText = "12, Orange Blvd"
Set textBox = groupBox.City
Call textBox.Click(72, 9)
textBox.wText = "Grovetown, CA"
Set textBox = groupBox.State
Call textBox.Click(98, 9)
textBox.wText = "US"
Set textBox = groupBox.Zip
Call textBox.Click(31, 12)
textBox.wText = "111155"
groupBox.MasterCard.ClickButton
Set textBox = groupBox.CardNo
Call textBox.Click(53, 12)
textBox.wText = "555777555888"
groupBox.ExpDate.wDate = "5/6/2005"
' Creating checkpoints
Call aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.Price, "wText", cmpEqual, "$80", False)
Call aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.Discount, "wText", cmpEqual, "15%", False)
Call aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.groupBox1.Total, "wText", cmpEqual, "1360", False)
' Closing the Order form
orderForm.ButtonOK.ClickButton
' Closing the application
mainForm.Close
orders.dlgConfirmation.btnNo.ClickButton
End Sub
DelphiScript
procedure Test1;
var orders : OleVariant;
var mainForm : OleVariant;
var orderForm : OleVariant;
var groupBox : OleVariant;
var numericUpDown : OleVariant;
var textBox : OleVariant;
begin
// Launching the Orders application
TestedApps.RunAll;
// Opening the Order form
orders := Aliases.Orders;
mainForm := orders.MainForm;
mainForm.MainMenu.Click('Orders|New order...');
// Populating the Order form
orderForm := orders.OrderForm;
groupBox := orderForm.Group;
groupBox.ProductNames.ClickItem('FamilyAlbum');
numericUpDown := groupBox.Quantity;
numericUpDown.Click(37, 9);
numericUpDown.wValue := 20;
groupBox.Date.wDate := '5/6/2005';
textBox := groupBox.Customer;
textBox.Click(67, 17);
textBox.wText := 'John Smith Jr';
textBox := groupBox.Street;
textBox.Click(31, 5);
textBox.wText := '12, Orange Blvd';
textBox := groupBox.City;
textBox.Click(47, 15);
textBox.wText := 'Grovetown, CA';
textBox := groupBox.State;
textBox.Click(82, 4);
textBox.wText := 'US';
textBox := groupBox.Zip;
textBox.Click(10, 8);
textBox.wText := '111155';
groupBox.MasterCard.ClickButton;
textBox := groupBox.CardNo;
textBox.Click(46, 9);
textBox.wText := '555777555888';
groupBox.ExpDate.wDate := '5/6/2005';
// Creating checkpoints
aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.Price, 'wText', cmpEqual, '$80', false);
aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.Discount, 'wText', cmpEqual, '15%', false);
aqObject.CheckProperty(Aliases.Orders.OrderForm.Group.groupBox1.Total, 'wText', cmpEqual, '1360', false);
// Closing the Order form
orderForm.ButtonOK.ClickButton;
// Closing the application
mainForm.Close;
orders.dlgConfirmation.btnNo.ClickButton;
end;
C++Script, C#Script
function Test1()
{
var orders;
var mainForm;
var orderForm;
var groupBox;
var numericUpDown;
var textBox;
// Launching the Orders application
TestedApps["RunAll"]();
// Opening the Order form
orders = Aliases["Orders"];
mainForm = orders["MainForm"];
mainForm["MainMenu"]["Click"]("Orders|New order...");
// Populating the Order form
orderForm = orders["OrderForm"];
groupBox = orderForm["Group"];
groupBox["ProductNames"]["ClickItem"]("FamilyAlbum");
numericUpDown = groupBox["Quantity"];
numericUpDown["Click"](37, 9);
numericUpDown["wValue"] = 20;
groupBox["Date"]["wDate"] = "5/6/2005";
textBox = groupBox["Customer"];
textBox["Click"](43, 7);
textBox["wText"] = "John Smith Jr";
textBox = groupBox["Street"];
textBox["Click"](31, 11);
textBox["wText"] = "12, Orange Blvd";
textBox = groupBox["City"];
textBox["Click"](24, 6);
textBox["wText"] = "Grovetown, CA";
textBox = groupBox["State"];
textBox["Click"](31, 8);
textBox["wText"] = "US";
textBox = groupBox["Zip"];
textBox["Click"](24, 17);
textBox["wText"] = "111155";
groupBox["MasterCard"]["ClickButton"]();
textBox = groupBox["CardNo"];
textBox["Click"](19, 7);
textBox["wText"] = "555777555888";
groupBox["ExpDate"]["wDate"] = "5/6/2005";
// Creating checkpoints
aqObject.CheckProperty(Aliases["Orders"]["OrderForm"]["Group"]["Price"], "wText", cmpEqual, "$80", false);
aqObject.CheckProperty(Aliases["Orders"]["OrderForm"]["Group"]["Discount"], "wText", cmpEqual, "15%", false);
aqObject.CheckProperty(Aliases["Orders"]["OrderForm"]["Group"]["groupBox1"]["Total"], "wText", cmpEqual, "1360", false);
// Closing the Order form
orderForm["ButtonOK"]["ClickButton"]();
// Closing the application
mainForm["Close"]();
orders["dlgConfirmation"]["btnNo"]["ClickButton"]();
}