Sunteți pe pagina 1din 61

QuickTest Professional (QTP)

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:

 Workcenter errors (updated 20080926)

 Changing workcenter names (updated 20080926)

 Handling drop down menus (updated 20080926)

 Handling drop down buttons

 Handling tabs

 Hitting “Enter” in text fields

 Opening a new window

 Clicking on dynamic text labels

 Dynamically changing window title

 Collapsing calendar buttons

 Auto suggestion text fields

 Recording a click on a view (new 20080926)

 Superfluous Script Lines (new 20080926)

31st June, 2008


Advanced techniques: Le-Huan Stefan Tran

 Setting output values 26th September, 2008


Rudolf Meier
 Parameterizing values

 Setting checkpoints

 Defining a global variable as a counter

 Setting up FUSE in a new action

 Passing parameters to a nested action

Errors:

 Search error “No records found”

 Create “New Sales Order” error

 Error running the “Test Batch Runner”

 Error using FUSE

 Error setting output values

 Not working clicks on buttons

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 ensure that the correct workcenter is selected: When recording, click on


the label of the workcenter
Important: Do not click on the image of the workcenter.
 Info: The click is now correctly recorded and named by QTP according to the
workcenter.

 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”

 Script your scenario:


 In QTP, record your scenario as usual – including the click on the problematic
workcenter
 Change the view to “Expert View”
 Choose the right action with the click on the workcenter

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”.

 Click on the item


 Click on the cell of the property “innertext” to modify the value

 Insert a regular expression:


 Click on the button with the symbol <#>
 Check “Regular expression”
 Hit “Yes” to treat special characters literally

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”

 1st step – Navigate to the drop down menu:


 Start the Internet Explorer and log on
 Navigate to the page with the drop down menu

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.

 Use the “Step Generator”:

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”

 2nd step – Navigate to the item (first possibility):


 Click on the text field to expand the drop down menu
 Move your mouse cursor several times up and down over the entries of
the drop down menu
 Move your mouse cursor over the entry you want to select
 Info: Now, the drop down menu will not collapse when you change the focus to
QTP. For some drop down menus this procedure for keeping the list open when
changing focus to QTP does not work. If this is the case, use the second
possibility below.

 2nd step – Navigate to the item (second possibility):


 In the QTP script, place the curser on an empty line below the command
entered before when using the step generator.
 Switch on recording. Record opening the drop down list and selection of the
correct entry. Note that this is not recorded in an executable way by QTP. We

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.

 Choose the code line to insert the step:


 In QTP, click into the right code line where you want to insert the click on the
item
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 menu.

 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 item of the drop down menu

 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

 Locate the button in the Object Repository:


 Menu: Resources \ Object Repository…
 Expand the nodes to find the item of the drop down button
Usually, you have to expand the browser, the page and the frame to find the
item “link”.
For example: Expand “Home - SAP Business ByDesign”, “Home - SAP Business
ByDesign”, “contentAreaFrame” to find the link “Follow-up”.

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”

 Set the “innertext” to the name of the item, too


 Set the “html tag” to “SPAN”
 Hit “Add”
 Important: Make sure the new item is placed as an element of the frame
“contentAreaFrame”.
 Info: The desired item of the drop down button has been added to the Object
Repository of QTP.

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.

 Use the “Step Generator”:


 Menu: Insert \ Step Generator… or hit “F7”
 Click on the button with the colorful cube
 Expand the nodes to find your just created item

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”

 Insert second drag and final drop command and a wait:


 Copy the just inserted code line
 Paste it into the next line
 Paste it again into the next line
 Edit manually the command “Drag” of the last just pasted code line to “Drop”
 Info: You should now have two lines with “Drag” and one with “Drop”.

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.

 Error – “Duplicate names”:


 Info: The problem could arise that there are other entries with a similar text
like the entry of the drop down button you want to click on.
 Info: QTP will throw an exception “Duplicate names”
 Info: You need to specify the position of the desired

 In QTP, menu: Resources \ Object Repository…


 Expand the nodes to find the just created entry of the drop down button
Usually, you have to expand the browser, the page and the frame.
 Click on the item
 Click on the cell “Value” of the property “Type, Value”
 Click on the button with the three dots

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.

 Navigate to the tab:


 Start the Internet Explorer and log on
 Navigate to the page with the tab
 Important: The desired tab should not have been clicked on yet, i.e. the tab
should not be activated yet.

 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 tab
Info: To make it clearer, the code line should be an empty line.

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.

 Choose the submit command:


 In QTP, choose the “Expert View”
 Choose the right action
 Mark the right code line where you submit the value of the text field
 Delete this code line

22
 Insert workaround:
 Copy and paste the following code lines
 Modify the parameters in the brackets <…>

Set WshShell = CreateObject("WScript.Shell")


wait(Wait_BeforeAction)
Browser(<modify>).Page(<modify>).Frame(<modify>).WebEdit(<modify>).Cl
ick
WshShell.SendKeys "{ENTER}"
wait(Wait_AfterAction)
Set WshShell = Nothing

 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 whole code block with the
workaround.
 Insert the code lines to stop FUSE after the whole code block with the
workaround.
 The workaround to hit “Enter” is now completely surrounded by the commands
of FUSE.

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.

 Record to the critical step:


 Record your scenario to the step when you want to open a new window
 Perform the step to open the new window
 In QTP, click on the right code line after the just recorded step
Info: To make it clearer, the code line should be an empty line.

 Insert a new nested action:


 Menu: Insert \ Call to New Action…
 Set a proper name
For example: 02a_NewWindow
 Set the “Location:” to “After the current step”
 Hit “OK”
 Info: In the new action, you can record all clicks performed on the new
window. The action will be called just after the step opening the new window.
 The active action is now the just created action.

 Record steps on the new window:


 Now proceed with recording all steps on the new window in this action
 When you have finished, choose your old action to proceed with your scenario

 Optional: Set up FUSE:

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.

 Optional: Opening another window from within the new window:


 Note: When you would like to open a third window from within the second
window, create a new nested action in your just created nested action.
 Follow the steps analogue to opening a new window

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.

 Record your scenario:


 In QTP, record your scenario as usual – including the click on the text label

 Open the Object Repository:


 Menu: Resources \ Object Repository…
 Expand the nodes to find the desired text label in the tree diagram
 Click on the text label
 Click on the cell with the desired text to prepare for modifying the text

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.

 Choose the “Expert View”


 Choose the right action where the problematic window is used
 Menu: Resources \ Object Repository…
 Expand the nodes to find the desired button in the tree diagram

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”

 Insert a regular expression:


 Click on the cell with the desired text to prepare for modifying the text
 Click on the button with the symbol <#>
 Check “Regular expression”
 Hit “Yes” to treat special characters literally

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

 2st step: Add the property “title” to the “Browser” object:


 Choose the “Browser” belonging to the button
 Click on the button with the green “+”
 Choose the property “title”
 Hit “OK”

 Insert a regular expression:


 Click on the cell with the desired text to prepare for modifying the text
 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 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.

 Record your script and look for the problematic step:


 In QTP, record your script as usual including the step when clicking on the
calendar button to open the calendar.

 Choose the “Expert View”


 Choose the right action where the problematic calendar button is clicked on
 Find the line with the problematic click

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”

 Update Active Screen:


 Menu: Automation \ Update Run Mode
 Rightclick into the code line with the first command “Drag” and choose “Run
form Step”
 Important: Make sure the Internet Explorer is still showing the page with the
calendar button.
 Important: Make sure the option “Update Active Screen images and values” is
checked.
 Hit “OK” to run the four code lines

 Use the “Step Generator”:


 In QTP, click into the code line with the second command “Drop”
 In the active screen, scroll the view to make the expanded calendar visible

 Rightclick on the item you want QTP to click on


 Choose “Step Generator…”
 Hit “OK”
 Make sure that the tree diagram shows the correct field – usually
“WebElement”
 Important: Make sure the “Operation:” is set to “Click”
 Hit “OK”

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.

 Delete not working steps:


 In QTP, choose the “Expert View”
 Choose the right action
 Delete the code lines with the commands of entering text or hitting “Enter”

 Insert workaround:
 Insert the following code lines

Set WshShell = CreateObject("WScript.Shell") ' Enter (for search form)


wait(Wait_BeforeAction)
Browser("New Invoice - SAP Business").Page("New Invoice - SAP
Business").Frame("Web Dynpro Innerpage_2").WebEdit("WebEdit").Click
WshShell.SendKeys "<enter text to be typed in>"
wait(5)
WshShell.SendKeys "{ENTER}"
wait(Wait_AfterAction)
Set WshShell = Nothing

 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:

 Record the click using the step generator

 Info: The click is now correctly recorded and executed by QTP.

 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 view.

 Make sure that the “Operation:” is set to “Click”


 Hit “OK”

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

(can always be removed)

…. WinStatusBar("msctls_statusbar32").Click

(can be removed unless explicitly needed for workaround)

Examples are given in the following screen shot.

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”.

 Mark the desired text to save:


 In QTP, choose the “Expert View”
 Choose the right action
 Click into the right code line with the active screen showing the value to save
 Mark the desired value in the active screen

 Insert a text output:


 Rightclick on the mark and choose “Insert Text Output…”
Important: Do not choose “Insert Output Value…”.
 Change the “Name:” following the naming convention:
Output_<name of value>
 Set “Insert statement” to “Before current step”

 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”.

 Mark the code line with the specific value:


 In QTP, choose the “Expert View”
 Choose the right action
 Click into the right code line where you have entered the specific value

 Parameterize the value:


 Choose the “Keyword View”
 Click into the cell of the marked code line named “Value”
 Click on the just appeared purple button “<#>”

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.

 Mark the desired text to check:


 In QTP, choose the “Expert View”
 Choose the right action
 Click into the right code line with the active screen showing the value to check
 Mark the value in the active screen

 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.

 Define the global variable in the global data table:


 In QTP, choose the tab “Data Table” in the bottom-left corner.
 Doubleclick on the header cell named with a character of an unused column,
for example “C”
 Enter a name for the global variable, for example “Counter”
 Hit “OK”
 The global variable has been set and can now be accessed by any action.

 Doubleclick on the cell below your just renamed header cell


 Enter “0” (zero)
 Hit “Enter”
 Important: Do not forget to press “Enter” to confirm the value.

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.

DataTable("Counter", dtGlobalSheet) = DataTable("Counter", dtGlobalSheet) +


1

 Insert the if-structure and the commands of FUSE:

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.

If DataTable("Counter", dtGlobalSheet) = 4 Then


Browser(<edit to match the code line>).Page(<edit to match the code
line>).Sync
JavaWindow("Measurement GUI").JavaButton("Start").Click
wait DataTable("Wait_BeforeAction", dtGlobalSheet)
End If

 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.

If DataTable("Counter", dtGlobalSheet) = 4 Then


Browser(<edit to match the code line>).Page(<edit to match the code
line>).Sync
wait DataTable("Wait_AfterAction", dtGlobalSheet)
JavaWindow("Measurement GUI").JavaButton("Stop").Click
End If

 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.

 Add the buttons of FUSE to the Object Repository:


 Menu: Resources \ Object Repository…
 Menu: Object \ Add Object to Local…
 Click on the “Start” button of FUSE
 Important: Make sure the “Start” button is active. Otherwise click on the
“Stop” button first.

 Menu: Object \ Add Object to Local…


 Click on the “Stop” button of FUSE
 Important: Make sure the “Stop” button is active. Otherwise click on the
“Start” button first.

 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.

 Prepare your script:


 In QTP, record your scenario as usual – including the call to a nested action
 Choose the “Expert View”
 Choose the nested action to which you want to pass parameters

 Insert input parameters:


 Menu: Edit \ Action \ Action Properties… \ Parameters
 Click on the button with the green “+” next to the “Input parameters”
 Enter a “Name” for your parameter
 Choose a “Type”
 Note: You might also modify the “Default Value”.

 Repeat the last three steps with every parameter you want to pass
 Hit “OK”

 Call the nested action with parameters:


 Choose the action which calls the nested action
 Look for the code line with the call of the nested action
For example: RunAction "Action3", oneIteration
 Now complete the code line with your desired parameters
o Each parameter has to be seperated by a comma “,”
o For example: RunAction "Action3", oneIteration, “Hello World!”, 10

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”.

 Choose the set command:


 In QTP, choose the “Expert View”
 Choose the right action
 Mark the right code line where you insert the value into the text field

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

 Insert output value:


 In the active screen of QTP, mark the desired value.
 Instead of rightclicking and choosing “Insert Text Output…”, choose “Insert
Output Value”
 Info: Now the whole item is stored in the global data table instead of just the
desired value.

 Choose the right property:


 In the following window, check the property containing your desired value.
 For example: Check “innertext” to gain the number of the sales order.

 Make sure the “Location” is set to “Global sheet”


 Modify the names as you like

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:

DataTable("<match output value name>", dtGlobalSheet) =


Replace(DataTable("<match output value name>", dtGlobalSheet), "<enter
string to be deleted> ", "")

 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.

 Change command “Click”:


 In QTP, choose the active screen and the right action.
 Locate the step with the click on the desired button.
 Copy and paste the code line

 Replace the “Click” of the first line with “Drag”


 Replace the “Click” of the second line with “Drop

 Finished:
 This is a very common workaround to fix those kinds of errors.

61

S-ar putea să vă placă și