Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
workarounds
When recording, there are certain clicks which are not correctly recorded by QTP. In
those cases, we have to manually add workarounds. In the first part, this document will
guide you through the process of inserting appropiate workarounds.
The second part of this document deals with various techniques of creating more complex
scenarios while the last part is about common errors in the process of scripting with QTP.
The newest versions of this document and the template are always available here:
\\dwdf029\AP\public\Product_Standard_Workfolder\Product_standard_coordinators\Perfo
rmance\Automated test\Documentation + Template
Classic workarounds:
Handling tabs
Setting checkpoints
Errors:
2
Workcenter errors
Problem:
When recording the script
o a wrong workcenter is selected or
o the workcenter to be selected is hidden.
Solution:
To record a click on a workcenter that is not visible on the initial screen: When
recording, navigate to the workcenter using the single arrow button, then click
on the label of the work center. QTP will also record the arrow-clicks, they can
be removed from the script. See next screen shot.
3
4
Changing workcenter names
Note added 26-September 2008: This workaround is still valid. However, I have
not been able to find abbreviated work center names, so this workaround might
be obsolete.
Line of action:
Info: Long workcenter names can be displayed in several ways, so QTP could
get confused.
For example: “Product and Service Po…” or “Product and Service Portfolio”
5
Open the Object Repository:
Menu: Resources \ Object Repository…
Expand the nodes to find the desired workcenter in the tree diagram
Info: Usually, the desired item is a “WebElement”.
6
Replace the changing / dynamic part of the text with the wildcard “.+”
For example: The last part of the name of the workcenter “Product and Service
Po…” is dynamic.
Change it to: “Product and Service .+”
Hit “OK”
Note: There are various other regular expressions featured by VBScript. Please
refer to http://www.aspheute.com/artikel/20000829.htm
Info: The value of the property “Name” is not important for QTP to recognize
the workcenter. It is just a unique identifier.
So we do not need to insert a regular expression there.
Finished:
Now, once long workcenter names have become harmless, we can concentrate
on scripting!
7
Handling drop down menus
Line of action:
Info: QTP has massive problems of handling drop down menus.
Info: You have to add those steps manually.
Requirements:
In QTP, choose the “Expert View”
Choose the right action
Delete any lines with a reference to the drop down menu – usually this is the
code line with the click on the “WebButton”
8
Choose the code line to insert the step:
In QTP, choose the “Expert View”
Choose the right action
Click into the right code line where you want to insert the click on the drop
down menu
Info: To make it clearer, the code line should be an empty line.
9
Menu: Insert \ Step Generator… or hit “F7”
Click on the button with the colorful cube
Change the active window to the Internet Explorer
Change the active window back to QTP
Click on the button with the outstretched index finger
Info: The active window will automatically changed to the Internet Explorer.
Now click on the text field of the drop down menu
Important: Do not click on the arrow button.
Make sure that the tree diagram shows the correct field – usually “WebEdit”
Hit “OK”
Important: Make sure that the “Operation:” is set to “Click”
Hit “OK”
10
just use the lines produced by QTP to keep the list open. Note that the lines
produced by this recording have to be removed again later.
Now close browser windows and FUSE, and execute the script. It will proceed
to the point where the entry in the drop down list is supposed to be selected.
It will hang at this point as it cannot execute this step. Stop the execution.
Now the drop down is displayed and does not collapse when focus is set to the
QTP window and we can proceed.
Remove the lines which were entered by the recording above.
Make sure that the tree diagram shows the correct item
Hit “OK”
Make sure that the “Operation:” is set to “Click”
Hit “OK”
11
Optional: Insert measurement:
When you would like to measure the step with the command “Enter”, you have
to take care of inserting the commands of FUSE properly.
Insert the code lines to start FUSE before the two code lines with the
workaround.
Insert the code lines to stop FUSE after the two code lines with the
workaround.
The workaround to hit “Enter” is now completely surrounded by the commands
of FUSE.
Finished:
Info: The drop down menu is now correctly handled.
12
Handling drop down buttons
Line of action:
Info: QTP does not record the step when clicking on a item of a drop down
button.
Info: You have to add this step manually.
Requirements:
In QTP, choose the “Expert View”
Choose the right action
Make sure that the click to expand the drop down button has been recorded
correctly
13
Define a new test object:
Click on the frame “contentAreaFrame”
Menu: Object \ Define New Test Object…
Set the “Environment” to “Web”
Set the “Class” to “WebElement”
Set the “Name” to the name of the item you want to click after you expanded
the drop down button
For example: “Phone Call”
14
Choose the code line to insert the step:
In QTP, choose the “Expert View”
Choose the right action
Click into the right code line where you want to insert the click on the item of
the drop down button
Info: To make it clearer, the code line should be an empty line.
Info: The code line before should be the click to expand the button.
15
For example: Expand the nodes browser “Home – SAP Business ByDesign”, the
page “Home – SAP Business ByDesign”, the frame “contentAreaFrame” and
click on the web element “Phone Call”
Hit “OK”
Set the “Operation:” to “Drag”
Hit “OK”
16
Optional: Insert measurement:
When you would like to measure the step with the command “Enter”, you have
to take care of inserting the commands of FUSE properly.
Insert the code lines to start FUSE before the three code lines with the
commands “Click”, “Drag” and “Drop”.
Insert the code lines to stop FUSE after the three code with the commands
“Click”, “Drag” and “Drop”.
The workaround to choose an item of the drop down button is now completely
surrounded by the commands of FUSE.
17
Set “Identifier type:” to “Location”
Set “Identifier value:” to the position of the desired entry in the drop down
menu
Info: Counting starts with 0. For example, for the first entry set 0.
Hit “OK”
Finished:
Info: The drop down button is now correctly handled.
18
Handling tabs
Line of action:
Info: QTP does not record the step when clicking on a tab.
Info: You have to add this step manually.
19
Use the “Step Generator”:
Menu: Insert \ Step Generator… or hit “F7”
Click on the button with the colorful cube
Change the active window to the Internet Explorer
Change the active window back to QTP
Click on the button with the outstretched index finger
Info: The active window will automatically changed to the Internet Explorer.
Now click on the desired tab
Important: The desired tab should not have been clicked on yet, i.e. the tab
should not be activated yet.
Make sure that the tree diagram shows the correct tab
Hit “OK”
Make sure that the “Operation:” is set to “Click”
Hit “OK”
20
Finished:
Info: The code line with click on the tab has just been correctly inserted.
21
Hitting “Enter” in text fields
Line of action:
Info: We enter a value into a text field of a search mask. To submit the value,
we hit “Enter”.
Info: When running the script, the “Enter” command is not working.
22
Insert workaround:
Copy and paste the following code lines
Modify the parameters in the brackets <…>
23
Finished:
Info: The submit command via “Enter” should now be appropiately executed.
24
Opening a new window
Line of action:
Info: There are situations where a click opens a new window. You want to
record clicks performed on the new window.
Info: Because QTP often gets confused concerning several windows, we need
to create a new nested action.
25
Note: When you would like to measure a step in the new window with FUSE,
you need to add the buttons of FUSE to the Object Repository of QTP.
Please refer to the workaround Set up FUSE in a new action in this document.
The buttons of FUSE can now be correctly recognized by QTP. Just add the
start and stop commands of FUSE as usual.
26
Clicking on dynamic text labels
Line of action:
Info: You want to click on a text labels whose text is partly changing.
Info: You have to use regular expressions to make QTP dynamically
recognize the text label.
27
Insert a regular expression:
Click on the button with the symbol <#>
Check “Regular expression”
Hit “Yes” to treat special characters literally
Replace the changing / dynamic part of the text with the wildcard “.+”
For example: The value in brackets of the text label “Today’s Quotes (2)” is
dynamic.
Change it to: “Today’s Quotes (.+)”
Note: There are various other regular expressions featured by VBScript. Please
refer to http://www.aspheute.com/artikel/20000829.htm
28
Finished:
The dynamically changing text label is appropiately handled.
29
Dynamically changing window title
Line of action:
Info: You have a window whose title is dynamically changing. To perform a
step on the window, you need to insert a regular expression to make QTP work
properly.
For example: “Sales Order Overview: 8036” could change to “Sales Order
Overview: 8037”; you want to click on close.
Record your script and find the button in the Object Repository:
In QTP, record your script as usual.
30
1st step: Add the property “title” to the “Page” object:
Choose the “Page” belonging to the button
Click on the button with the green “+”
Choose the property “title”
Hit “OK”
31
Replace the changing / dynamic part of the text with the wildcard “.+”
For example: The value of the text label “Sales Order Overview: 8036 - SAP
Business ByDesign” is dynamic.
Change it to: “Sales Order Overview: .+ - SAP Business ByDesign”
Note: There are various other regular expressions featured by VBScript. Please
refer to http://www.aspheute.com/artikel/20000829.htm
For example: The value of the text label “Sales Order Overview: 8036 - SAP
Business ByDesign” is dynamic.
Change it to: “Sales Order Overview: .+ - SAP Business ByDesign”
Finished:
The dynamically changing window title is now correctly handled.
32
Collapsing calendar buttons
Line of action:
Info: Clicking on a calendar button to open a calendar as well as choosing a
specific month and a day are very problematic.
33
Insert commands “Drag” and “Drop”:
Copy and paste the line three times into the next lines
Change the command “Click” of the first and third code line to “Drag”
Change the command “Click” of the second and forth code line to “Drop”
34
Clicking on further items of the calendar:
Insert the extra commands “Drag” and “Drop” and run the steps with the
option updating the active screen activated
Work with the active screen and the step generator to insert your desired step
Clean up code:
Delete the code lines with the second command “Drag” and the second
command “Drop”
35
Finished:
Info: You have just gained the ability to conquer annoying calendar buttons.
Level up!!111einself ^^
36
Auto suggestion text fields
Line of action:
Info: Typing text in a text fields with the feature “auto suggestion” is
problematic.
Insert workaround:
Insert the following code lines
The step with the “click” on the “WebEdit” has to be manually recorded with
the “Step Generator” – cf. “Use the “Step Generator”” of the chapter Handling
tabs
Replace the brackets “<…>” with your desired text to be typed in into the text
field
Important: You should use only a maximum of four characters.
Otherwise, the auto suggestion feature will turn on and ignore all following
“Send Keys” commands.
Note 20080917: This is no longer true for GFP, use complete name!
Info: With typing in four characters the auto suggestion feature should suggest
your desired entry at the top, so “Enter” will automatically choose the entry.
If not, you can make use of the abbreviation of each entry. Replace the
brackets “<…>” with the abbreviation instead.
37
Finished:
Info: Thank you, thank you, thank you – you’re far too kind! This is finally my
last official act – see you in six months!
38
Recording a click on a view
Problem:
When running the script
o The click on a view is not executed
Solution:
39
Superfluous Script Lines
Information:
Some Script Lines are created by QTP which are not needed and can be removed.
In particular, this is true for the following line types:
…. WebButton("Submit Query").Click
…. WinStatusBar("msctls_statusbar32").Click
40
Setting output values
Line of action:
Info: You need to save a value displayed on the screen.
Info: Later on, you can use to saved value by inserting it in text fields - cf. the
workaround “Parameterizing values”.
Click on “Modify…”
Change the “Name” following the naming convention:
Value_<name of value>
Set “Output Types” to “DataTable”
Set “Location in Data Table” to “Global sheet”
Hit “OK” two times
41
Finished:
Info: The marked value will be saved in the global data table of QTP.
Info: It can be accessed via parameterzing another value - cf. the workaround
“Parameterizing values”.
42
Parameterizing values
Line of action:
Info: In your script, you have manually entered a specific value into a text
field or a edit box. Now you want to use a dynamic value of the global data
table of QTP instead.
Example: You want to search for a Sales Order whose ID you have saved
before.
Requirements:
Info: First of all, it is necessary to set an output value – cf. the workaround
“Setting output values”.
43
Choose the value of the global data table:
Choose “Parameter”
Set “Parameter” to “DataTable”
Set “Name:” to your created output value
Set “Location in Data Table” to “Global sheet”
Hit “OK”
Finished:
44
Info: When running the script, QTP will dynamically access the value of the
global data table.
45
Setting checkpoints
Line of action:
Info: When you want to verify a displayed value with an expected value, you
can use checkpoints.
Insert a checkpoint:
Rightclick on the mark and choose “Insert Text Checkpoint…”
Change the “Name:” following the naming convention:
Checkpoint_<name of value>
Make sure that the “Constant” is set to the right text
Set “Insert statement” to “Before current step”
Hit “OK”
46
Finished:
Info: The checkpoint has just been correctly set.
Info: After running the script, a result window will pop up showing the success
or failure of the run. When you expand the nodes, you can see the result of
the checkpoint.
47
Defining a global variable as a counter
Line of action:
Info: Your scenario loops over a step for a certain number of times. Only at the
last loop, you want to measure the step with FUSE.
Solution: You check with an if-structure when the loop counter reaches your
desired value and start / stop FUSE.
Problem: If the step is performed within a nested action, you cannot access
the loop counter of the outer action.
Solution: You have to define a global variable in the global data table as a
counter.
48
Increment the counter:
In QTP, choose the “Expert View”
Choose the right nested action where you want to measure the step
Copy and paste the following code line into the first code line to increment the
counter
Info: When you have named your global variable differently, modify “Counter”
in the code line.
49
Insert the following code lines before the step you want to measure
Info: When you have named your global variable differently, modify “Counter”
in the code line.
Info: Modify the value “4” to match your test case.
Insert the following code lines after the step you want to measure
Info: When you have named your global variable differently, modify “Counter”
in the code line.
Info: Modify the value “4” to match your test case.
Set up FUSE:
Please refer to the workaround Set up FUSE in a new action in this document
Finished:
Info: It is now possible to use a global counter that is independent of other
actions.
50
Setting up FUSE in a new action
Line of action:
Info: When you would like to measure a step in a new action with FUSE, you
need to add the buttons of FUSE to the Object Repository of QTP.
Preparations:
In QTP, run your script to step you want to measure
Change the active window to FUSE
Change the active window back to QTP
Important: Make sure that the current action is the right action with the step
to measure.
Finished:
The buttons of FUSE can now be correctly recognized by QTP. Just add the
start and stop commands of FUSE as usual.
51
Passing parameters to a nested action
Line of action:
Info: We want to call a nested action passing parameters to control the
program flow.
Info: This could be useful when we pass the current loop index and the loop
maximum to a nested action. In this action, we only measure the step when
the current loop equals the loop maximum, e.g. when we are in the last loop.
Repeat the last three steps with every parameter you want to pass
Hit “OK”
52
Important: The order of the parameters corresponds to the order of the input
parameters you have created.
Note: Instead of using specific values you can also parameterize the
parameters.
Finished:
Note: You are now capable of using an advanced technique to control your
program flow.
53
Search error “No records found”
Line of action:
Info: We enter a value into a text field of a search mask. When hitting “Go”,
the just entered value disappears and it says “No records found”.
54
Duplicate this code line:
Copy the marked code line
Insert it into the next line
Finished:
Info: The inserted value should now be kept. The search should be successful.
55
Create “New Sales Order” error
Problem:
When we create a “New Sales Order”, you enter the “Product ID” and then the
“Quantity”. When hitting “Enter”, the “Product ID” disappears.
Solution:
Enter the “Quantity” first
Then type in the “Product ID”
Click into the “Quantity” text field again
Hit “Enter”
56
Error running the “Test Batch Runner”
Problem:
When runnning the “Test Batch Runner” of QTP, several items like buttons are
not recognized.
You might have the SAP plugin installed, so QTP is not able identify items
correctly.
Solution:
Menu: Start \ Control Panel \ Add and Remove Programs / Programs and
Features
Select “QuickTest Professional SAP Plugin”
Uninstall
57
Error using FUSE
Problem:
FUSE crashes throwing a dump.
The button “Stop” does not work.
Solution:
Update your SAP GUI.
Make sure that the properties of the action “01_LogOn” and “03_LogOff” are
set correctly.
58
Error setting output values
Problem:
Using the advanced technique to set an output value does not work.
The desired value is not stored in the global data table
59
Cut the stored value:
To extract the desired value of the stored string insert the following code line.
Modify the parameters in the brackets:
For example, we want to get the number of in the string “SalesOrder: 8331”:
DataTable("value_myOutput", dtGlobalSheet) =
Replace(DataTable("value_myOutput", dtGlobalSheet), "SalesOrder: ", "")
Finished:
Now the output value is ready to be used in further steps.
60
Not working clicks on buttons
Problem:
When running a script with correctly recorded click on a button, the click might
fail.
Finished:
This is a very common workaround to fix those kinds of errors.
61