Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
* Per-action
* Shared
Tell about Per-action repository modes
In this, for each action a seperate object repository file is created. So object1 in Action1 is different from the same object1 in
Action2
This mode is most useful, when the object does not change frequently and a few actions are associated with the test. If the
object changes in the application, then we need to change each of the object repositor.
Tell about Shared object repository modes
In this, common object repository file can be used for muliple actions and multile tests. So Object1 is action1 is same for
Action2, because all the objects are saved at one place. Here if the object changes, then we need to update a single object
repository file.
What are the Advantage & Disadvantge Per-action repository ?
Advantage
* As you record operations on objects in your application, QuickTest automatically stores the information about those objects
in the appropriate action object repository.
* When you save your test, all of the action object repositories are automatically saved with the test as part of each action
within the test. The action object repository is not accessible as a separate file (as is the shared object repository).
Disadvantages
* Modifying the test object properties, values, or names in one object repository does not affect the information stored for the
same test object in another object repository or in other tests - Time Consuming
* If you add objects to one of the split actions, the new objects are added only to the corresponding action object repository.
What are the Advantage & Disadvantge Shared object repository ?
Advantage
* Only one instance of the object in the repository so reduce the repetitions
* one time change to the object properties would bring change in every script using the object
Disadvantge
* Complexity increase as objects of all the action are in the same repository
What is Check points ?
A checkpoint verifies that expected information is displayed in an Application while the test is running. Checkpoints are used
to compare actual and expected results.
How many Check points are there in QTP ?
They are 4 types of checkpoints
* GUI Check point
* Bitmap Checkpoint
* Database Checkpoint
* Test Checkpoint
What is the use of Check points ?
The Check points is useful to get the point in time from where to begin the recovery in case of failure.
Can we change the name of the Check points ?
No, QTP is do not allow to change the name of Check point, because these class names are internally built. But in version 9
(just released) it is possible to cahange not in previous versions
What is Transaction ?
A Transaction is a logical unit of work that comprises one or more SQL statements executed by a single user. or It is a group
of statements between two commits
What is use of Step Generator ?
Step Generator is used to insert a statement(function ro method) of a particular object which is available in the Object
Repository
What is Source Control ?
The practice of tracking changes made to code is called Source Control.
Familiar Source control Tools are CVS, VSS, ClearCase etc
What is Batch testing ?
Group of tests executing sequentially one by one is called Batch Testing. Every test Batch consists of mutiple dependent
test cases. In those batches every end state is base state to next case. Test batch is also known as Test suit or Test belt.
Generally Test engineers are executing test programs as a batches because "End state of one test is base state to another
test".
The result of one Script failure or pass , fails or passes the whole batch test.
What will you when Object is not indentifed by the Obect Repository ?
Use Smart identifcation.
What is Smart identifcation ?
Smart Identification is used by QTP, whenever it is unable to identify any object during run time. While identifying an object,
QTP tries to match the mandatory properties first, if it couldn't find the object, then it adds assistive properties one by one to
identify the object correctly. This operation is done by smart identifier and it is displayed in the results section along with one
warning message. It's generally used to identify Web elements only.
What is Envoirement variable ?
Envoirement variable is variable which is global through the testing.
What is the typesof Envoirement variable ?
There are 3 types of environmental variables
* User-Defined Internal
* User-Defined External
* Built-In
What are Exception in QTP ?
The four exceptions are
* Pop exception
* Object state
* Test run error
* Application crash
Can We use Test Director with QTP ?
Yes. We cant use Test Director 7.2 with QTP 8.2. Because QTP 8.2 supports QC (Quality Center)
Recording
Playback
Method Argument
Data Driven
Dynamic
Preparing to recoding
Recording
Enhancing your script
Debugging
Run
Analyze
Report Defects
SMART Identification
Smart Identification is nothing but an algorithm used by QTP when it is not able to recognize one of the object. A very
generic example as per the QTP manual would be, A photograph of a 8 year old girl and boy and QTP records identification
properties of that girl when she was 8, now when both are 10 years old then QTP would not be able to recognize the girl.
But there is something that is still the same, that is there is only one girl in the photograph. So it kind of PI (Programmed
intelligence) not AI.
When should i use SMART Identification?
Something that people don't think about too much. But the thing is that you should disable SI while creating your test cases.
So that you are able to recognize the objects that are dynamic or inconsistent in their properties. When the script has been
created, the SI should be enabled, so that the script does not fail in case of small changes. But the developer of the script
should always check for the test results to verify if the SI feature was used to identify a object or not. Sometimes SI needs to
be disabled for particular objects in the OR, this is advisable when you use SetTOProperty to change any of the TO
properties of an object and especially ordinal identifiers like index, location and creationtime.
Descriptive Programming
Descriptive programming is nothing but a technique using which operations can be performed on the AUT object which are
not present in the OR. For more details refer to http://bondofus.tripod.com/QTP/DP_in_QTP.doc (right click and use save
as...)
Recovery Scenarios
What is a Recovery Scenario?
Recovery scenario gives you an option to take some action for recovering from a fatal error in the test. The error could
range in from occasional to typical errors. Occasional error would be like "Out of paper" popup error while printing
something and typical errors would be like "object is disabled" or "object not found". A test case have more then one
scenario associated with it and also have the priority or order in which it should be checked.
What does a Recovery Scenario consists of?
Trigger: Trigger is nothing but the cause for initiating the recovery scenario. It could be any popup window, any test error,
particular state of an object or any application error.
Action: Action defines what needs to be done if scenario has been triggered. It can consist of a mouse/keyboard event,
close application, call a recovery function defined in library file or restart windows. You can have a series of all the specified
actions.
Post-recovery operation: Basically defined what need to be done after the recovery action has been taken. It could be to
repeat the step, move to next step etc....
When to use a Recovery Scenario and when to us on error resume next?
Recovery scenarios are used when you cannot predict at what step the error can occur or when you know that error won't
occur in your QTP script but could occur in the world outside QTP, again the example would be "out of paper", as this error
is caused by printer device driver. "On error resume next" should be used when you know if an error is expected and dont
want to raise it, you may want to have different actions depending upon the error that occurred. Use err.number &
err.description to get more details about the error.
Library Files or VBScript Files
How do we associate a library file with a test ?
Library files are files containing normal VBScript code. The file can contain function, sub procedure, classes etc.... You can
also use executefile function to include a file at run-time also. To associate a library file with your script go to Test>Settings... and add your library file to resources tab.
When to associate a library file with a test and when to use execute file?
When we associate a library file with the test, then all the functions within that library are available to all the actions present
in the test. But when we use Executefile function to load a library file, then the function are available in the action that called
executefile. By associated a library to a test we share variables across action (global variables basically), using association
also makes it possible to execute code as soon as the script runs because while loading the script on startup QTP executes
all the code on the global scope. We can use executefile in a library file associated with the test to load dynamic files and
they will be available to all the actions in the test.
Test and Run-time Object
What is the difference between Test Objects and Run Time Objects ?
Test objects are basic and generic objects that QTP recognize. Run time object means the actual object to which a test
object maps.
Can i change properties of a test object
Yes. You can use SetTOProperty to change the test object properties. It is recommended that you switch off the Smart
Identification for the object on which you use SetTOProperty function.
Can i change properties of a run time object?
No (but Yes also). You can use GetROProperty("outerText") to get the outerText of a object but there is no function like
SetROProperty to change this property. But you can use WebElement().object.outerText="Something" to change the
property.
Action & Functions
What is the difference between an Action and a function?
Action is a thing specific to QTP while functions are a generic thing which is a feature of VB Scripting. Action can have a
object repository associated with it while a function can't. A function is just lines of code with some/none parameters and a
single return value while an action can have more than one output parameters.
Where to use function or action?
Well answer depends on the scenario. If you want to use the OR feature then you have to go for Action only. If the
functionality is not about any automation script i.e. a function like getting a string between to specific characters, now this is
something not specific to QTP and can be done on pure VB Script, so this should be done in a function and not an action.
Code specific to QTP can also be put into an function using DP. Decision of using function/action depends on what any one
would be comfortable using in a given situation.
Checkpoint & Output value
What is checkpoint?
Checkpoint is basically a point in the test which validates for truthfulness of a specific things in the AUT. There are different
types of checkpoints depending on the type of data that needs to be tested in the AUT. It can be text, image/bitmap,
attributes, XML etc....
harnesses... there's no way to come up with one catch-all that will "convert" WR stuff to QTP stuff. So the idea is to reuse
WR stuff via the QTP/WR Integration.
Let me reiterate this again, so there is no confusion:
WINRUNNER AND WINRUNNER SUPPORT ARE NOT GETTING PHASED OUT.
WinRunner will be able to call QuickTest Pro scripts.
QuickTest Pro will be able to call WinRunner scripts.
What one cannot do, the other will.
Licensing
To review, there are two ways to licenses a product: node-locked and floating. Node-locked refers to assigning the app to
one machine; floating allows a license to be shared between machines at any given point in time (2 floating licenses allow
the app to be accessible from an entire lab's worth of PC's but can only have 2 instances running at any given point in time).
Before I continue, I need to state that I cannot tell you exact pricing that MI has set up for the licenses, however, I *can* give
you an idea of what costs more one way than the other.
That said, we've got:WR Node-Locked
WR Floating
QTP Node-Locked
QTP Floating
OFT Node-Locked
OFT Floating
OFT? What's that? That is the new "Optane Functional Testing" license (NOTE: This is a working name for the license, it
may change). It is WR and QTP with the integration. I'll get to that later....
If you're using WR and now need the ability to test in an environment not supported by WR, you have 3 options:
Upgrade WR to QTP. You LOSE WinRunner here, trading it in for QTP. If you don't have a whole lot invested into
WinRunner yet, and you don't need to test in environments exclusive to WR, this might be a viable option for you. If you
have thousands of WinRunner scripts, this probably is not the way to go.
Add QTP. Given that there will be (is) an integration for WR and QTP, adding a couple QTP licenses may be an option.
Move to the Optane Functional Testing license. You can either purchase these outright or upgrade your WR license to an
OFT license. Upgrading a WR license to an OFT license sounds a lot like adding QTP, right? Sure does. But itll costs less.
It's VERY IMPORTANT to consider your node-locked vs. floating schema here. I can't tell you which way to go. You need to
look at your lab environment, and how many licenses of which you really need, but there are some caveats to this:
1 node-locked OFT license allows you to have both WR and QTP installed on ONE MACHINE, and a WR/QTP script can
call a QTP/WR script, on the one license.
1 floating OFT license allows you to have ONE INSTANCE of WR or QTP active, accessible from MULTIPLE MACHINES.
That means if you are in a floating license schema you CANNOT HAVE ONE APP CALL THE OTHER'S SCRIPTS WITH
ONLY ONE FLOATING OFT LICENSE. Those in smaller companies need to take this into consideration.
Big confusion: The original information about Optane Functional Testing licenses did not give the impression that there was
a node locked option. It looked like there was going to be "out of reach" costs to get into WR/QTP. Mercury is going back to
the wording on how the FT licensing schema is being described and make it less confusing.
There will even be a CD install for OFT: It will have both WR and QTP installs on the disk. Expect to see this at the end of
Q2 with the QTP 6.1 release.
WR/QTP Comparisons and "In The Future"
WinRunner 7.6 is scheduled to come out next quarter. WinRunner 8.0 is scheduled to be released at the end of the year.
Beyond that, yes, there will be enhancements made to WinRunner.
WinRunner Both QuickTest Pro
Common: environments supported by both WinRunner and QuickTest. Includes IE, Netscape, Windows, Java, Visual Basic,
and terminal emulator (green screen) applications.
Emerging: environments supported by only QuickTest. Includes .Net; newer ERP/CRM environments such as mySAP and
Siebel 7.x; and Macromedia Flash.
Mercury Interactive is committed to providing ongoing support for WinRunner in all Classic and Common environments, and
is committed to ensuring that QuickTest works in all Common and Emerging environments. This means that, for instance,
when a new version of PowerBuilder is released and gains market acceptance, Mercury Interactive will build support for that
new version of PowerBuilder into WinRunner. When a new version of IE is released, Mercury Interactive will build support
for it in both WinRunner and QuickTest. As new versions of .Net, SAP, and Siebel are released, Mercury Interactive will
support those environments in QuickTest. This level of environment support will continue through 2003 and beyond. Mercury
Interactives goal is to ensure that customers can continue to realize the benefits of using our functional testing solutions in
their existing environments as these environments evolve.
QuickTest Pro and...
...TestDirector
The integration of QTP and TD is the same as it is for WR and TD. Test Sets, Test Runs, etc. are able to be created using
QuickTest Pro scripts. Since TD can handle both WR and QTP scripts in a Test Set, both can be in the same run.
...MS Excel
Just like you can create data tables using Microsoft Excel for WR scripts, you can do the same thing for the QTP data driven
scripts that you will create.
...Databases
According to Mercury, database testing via QTP is equal or better than via WR. QTP has:
Enhanced ODBC database import engine.
Provides same DB verification wizard that is in WR
Open extension of VB engine (COM based replay engine: can make direct calls to ODBC db at the object level)
Conclusion
There was a question about when to use one over the other outside of a scripting preference. QTP has reusable actions,
icon based script, active screen, and an integrated data table. It is really up to the individual and how your environment is
going to get set up. Those that are new to automated testing may find QTP easier in the long run. According to Mercury,
many of the lessons learned from WinRunner have been incorporated into QTP.
There are certain environments that WinRunner won't be able to go. This may be a matter of business decision or simply
WinRunner's architecture. The impression that I got from my conversations with Mercury was that they have no intention of
abandoning WinRunner or its users. Mercury is responding to market conditions where there is a greater focus on QuickTest
Pro. So you may have to use a QuickTest Pro solution, but you won't be forced into phasing out WinRunner.
Which way should you go? Again, that depends on your environment. If you have been using WinRunner and now you find
you need QuickTest Pro, there are a number of upgrade paths available. You'll be able to trade in licenses, add, convert,
etc.
How to locate and click on an item in a web table
1. Get the number of columns and rows in the table. This can be done using the RowCount and ColumnCount methods.
2. Loop through the cells in the table.
3. Get the data value from the cell. This can be done using the GetCellData method.
Note:
If the value you are looking for is not a text value, you may need to use an alternate method.
4. If the data is the value you want, use the ChildItem method to get a reference to the object you wish to click.
5. Use the Click method to click on the data item.
Example:
' Get the row count
rowcount = Browser("Browser").Page("Page").WebTable("The Web Directory").RowCount
connection utilities, mouse drivers, etc. It is possible that one of those processes, utilities, or services is causing a
conflict.
2. Check the processes that are running on the problem machine.
Start QuickTest Professional, and perform the actions needed to reproduce the problem.
Open the Task Manager (Start -> Run -> taskmgr.exe).
Note the processes which are running. Try to identify what the processes are for.
To determine if there is a conflict with a running process, end the processes one at a time. You can narrow down the list
somewhat by comparing the processes with those from a working machine. Once you have a list of unknown or different
processes, kill one of the processes and restart QuickTest Professional.
See if the problem reproduces. If the issue continues, repeat the steps with the next process in the Task Manager.
If you find a process that seems to be causing the problem, try killing that process only. Restart or relog into your
machine. Open the Task Manager and kill that process. Start QuickTest Professional and see if you can recreate the
problem. If you are unable to recreate the problem, then you most likely have found the conflicting process. Note, the
issue can be caused by a few processes running together (these processes are usually for the same utility or
application though).
3. Check the version of the DLLs that are in use. You will need to check the DLLs that are directly in use and, possibly,
the DLLs that are required by those DLLs. Use a utility that will give you a list of DLLs being used by an application.
Once you have this list, check the version of these DLLs with the versions from a working machine.
If you find versions that do not match, copy the DLLs from the working machine to the problem machine. Make sure you
back up the DLLs before replacing them. If the versions of those DLLs match, check the versions of the DLLs upon
which those DLLs rely. You can use Microsoft's Dependency Walker utility to determine which DLLs are used by another
DLL.
How to select a WebCheckBox using its adjacent text
Use the custom WebCheckBoxByLabel function (Internet Explorer only)
Note:
This function is not part of QuickTest Professional. It is not guaranteed to work and is not supported by Mercury
Customer Support. You are responsible for any and all modifications that may be required.
WebCheckBoxByLabel( parent, arg )
parent The Page object containing the checkbox item you want to select
arg The text to locate
This function uses the DOM object, so it will only work on Internet Explorer.
Function WebCheckBoxByLabel( parent, arg )
' Create a description for the WebCheckBox object
Set desc = Description.Create()
desc("type").Value = "checkbox"
desc("html tag").Value = "INPUT"
' Retrieve all WebCheckBox objects on the page
Set cbcol = parent.ChildObjects(desc)
cnt = cbcol.count
' Loop through the WebCheckBox objects
For obj = 0 to cnt-1
' Get the text next to the checkbox
text = cbcol(obj).object.getAdjacentText("afterend")
' Is this the text we're looking for?
If arg = Trim(text) Then
cbcol(obj).Set "ON"
Exit For
End If
Next
End Function
RegisterUserFunc "Page", "WebCheckBoxByLabel", "WebCheckBoxByLabel
Use the VBScript Filter function
Search value in an array:
The Filter function returns a zero-based array containing a subset of a string array based on a specified filter criteria.
Filter(InputStrings, Value[, Include[, Compare]])
InputStrings (Required) One-dimensional array of strings to be searched.
Value (Required) String to search for.
Include (Optional) Boolean value indicating whether to return substrings that include or exclude Value. If Include is True,
Filter returns the subset of the array that contains Value as a substring. If Include is False, Filter returns the subset of
the array that does not contain Value as a substring.
Compare (Optional) Numeric value indicating the kind of string comparison to use. See Settings section for values.
The Compare argument can have the following values:
vbBinaryCompare 0 Perform a binary comparison.
vbTextCompare 1 Perform a textual comparison.
If no matches of Value are found within InputStrings, Filter returns an empty array (the Ubound will be -1). An error
occurs if InputStrings is Null or is not a one-dimensional array.
The array returned by the Filter function contains only enough elements to contain the number of matched items.
Example 1:
ReDim myArray(
myArray(0) = "Mon 2"
myArray(1) = "Tues 3"
myArray(2) ="Wed 4"
myArray(3) ="Thurs 5"
myArray(4) ="Fri 6"
myArray(5) ="Sat 7"
myArray(6) ="Sun 8"
myArray(7) = "Mon 9"
myIndex = Filter(myArray, "Mon")
For i = 0 to Ubound(myIndex)
msgbox myIndex(i)
Next
Example 2:
ReDim myArray(5)
myArray(0) = "Mon"
myArray(1) = "Tues"
myArray(2) ="Wed"
myArray(3) ="Thurs"
myArray(4) ="Fri"
myIndex = Filter(myArray, "Sat")
If Ubound(myIndex) < 0 Then
The source directory contains the source code for the .DLL as well as the source code for the Visual Basic application
that the IsBusy script tests.
Note:
You can also synchronize on the cursor type (state). For information on how do get the cursor state, please refer to
Problem ID 44583 - How to determine the state of the mouse cursor.
Example:
' Get the handle of the application window or object
hwnd = Window("Notepad").GetROProperty("hwnd")
' Get the cursor type (state)
val = getCursorType (hwnd)
' Loop while the cursor is the specified type
Do While (val = "IDC_IBEAM") ' I-beam cursor
wait 1
val = getCursorType (hwnd)
Loop
The above example waits while the mouse cursor is in the I-Beam cursor state.
Use the custom FSBrowserRestore and FSBrowserMinimize functions
Note:
These functions are not part of QuickTest Professional. They are not guaranteed to work and are not supported by
Mercury Customer Support. You are responsible for any and all modifications that may be required.
To restore a full screen browser window to its original size, use the custom FSBrowserRestore function.
FSBrowserRestore(obj)
obj The Browser object
'@Description Restores a full screen browser to original size
'@Documentation Restore the full screen browser to its original size
Function FSBrowserRestore(obj)
' Press the Restore toolbar button.
obj.WinToolbar("nativeclass:=ToolbarWindow32", "window id:=0").Press "Restore"
End Function
RegisterUserFunc "Browser", "FSBrowserRestore", "FSBrowserRestore"
Example:
Browser("Yahoo!").FullScreen
wait 1
Browser("Yahoo!").FSBrowserRestore
To minimize a full screen browser, use the custom FSBrowserMinimize function.
FSBrowserMinimize(obj)
obj The Browser object
'@Description Minimizes a full screen browser
'@Documentation Minimize the full screen browser
Function FSBrowserMinimize(obj)
' Press the Minimize toolbar button.
End Function
RegisterUserFunc "Browser", "FSBrowserMinimize", "FSBrowserMinimize"
Note:
To restore a minimized full screen browser, you need to use the Window object Restore method. The
FSBrowserRestore method will not work.
Example:
Browser("Yahoo!").FullScreen
Browser("Yahoo!").FSBrowserMinimize
' Restore the minimized browser
Window("Microsoft Internet Explorer").Restore
To record the restore method:
1. Start recording.
2. Go to Test -> Low-Level Recording. This step starts Low-Level recording.
3. Click on the browser in the system task bar.
4. Go to Test -> Low-Level Recording. This step stops Low-Level recording. Alternatively, you can stop recording
completely.
Posted: Sun Oct 15, 2006 3:40 am
Use the Debug menu "Step Into" and "Step Over" options (F11 and F10)
Single stepping through a script can be done with the "Step Over" and "Step Into" actions under the Debug menu. You can
also use the F11 hotkey for Step Into, or the F10 hotkey for Step Over.
The Step Into option runs the current line of the script. If the current line calls a method, the method is displayed in the view
but is not performed. The Step Over option runs the current line of the script. When the current line calls a method, the
method is performed in its entirety, but is not displayed in the view.
To launch and single step through a script:
1. Open the desired test.
2. Press F11 to start the script run.
3. Select the test results location, and click <OK>.
4. Press F11 twice to engage the test flow.
5. Press F11 or F10 to enter the first action.
6. Press F11 or F10 repeatedly to single step the script.
To single step through a specified section of a script:
1. Open the desired script.
2. Place a breakpoint on the step you wish to start from.
3. Right-click on that step, and select "Run from step."
4. Select the test results location, and click <OK>.
5. Press F11 or F10 to step through the script as needed.
Example:
msgbox "one"
msgbox "two"
msgbox "three"
msgbox "four"
msgbox "five"
msgbox "six"
In the above script, you want to execute (one at a time) lines 3, 4, and 5. Place a breakpoint on line 3 (this is the msgbox
"three" line). Then right-click on line 3 and select Run from Step. The Run dialog will appear. Select the location for the test
results. This will either be a "new run results folder" or the "temporary run results folder". Click <OK> to close the dialog. The
yellow execution arrow will appear next to the third line. At this point, because there is a breakpoint on line 3, QuickTest
Professional will be in run mode, but will not be executing the test. Press F11 or F10. A message box will appear with the
text "three". Close the message box. The execution arrow will move down to line 4. Press F11 or F10 again. A message box
with the text "four" will appear. Close the message box. The execution arrow will move to line 5. Press F11 or F10 again. A
message box with the text "five" will appear. Close the message box. Since there are additional lines still in the script,
QuickTest Professional will still be in run mode (though it will be idle). Click the Stop button to end test execution.
Use the Debug menu "Step Into" and "Step Over" options (F11 and F10)
Single stepping through a script can be done with the "Step Over" and "Step Into" actions under the Debug menu. You can
also use the F11 hotkey for Step Into, or the F10 hotkey for Step Over.
The Step Into option runs the current line of the script. If the current line calls a method, the method is displayed in the view
but is not performed. The Step Over option runs the current line of the script. When the current line calls a method, the
method is performed in its entirety, but is not displayed in the view.
To launch and single step through a script:
1. Open the desired test.
2. Press F11 to start the script run.
3. Select the test results location, and click <OK>.
4. Press F11 twice to engage the test flow.
5. Press F11 or F10 to enter the first action.
6. Press F11 or F10 repeatedly to single step the script.
To single step through a specified section of a script:
1. Open the desired script.
2. Place a breakpoint on the step you wish to start from.
3. Right-click on that step, and select "Run from step."
4. Select the test results location, and click <OK>.
5. Press F11 or F10 to step through the script as needed.
Example:
msgbox "one"
msgbox "two"
msgbox "three"
msgbox "four"
msgbox "five"
msgbox "six"
In the above script, you want to execute (one at a time) lines 3, 4, and 5. Place a breakpoint on line 3 (this is the msgbox
"three" line). Then right-click on line 3 and select Run from Step. The Run dialog will appear. Select the location for the test
results. This will either be a "new run results folder" or the "temporary run results folder". Click <OK> to close the dialog. The
yellow execution arrow will appear next to the third line. At this point, because there is a breakpoint on line 3, QuickTest
Professional will be in run mode, but will not be executing the test. Press F11 or F10. A message box will appear with the
text "three". Close the message box. The execution arrow will move down to line 4. Press F11 or F10 again. A message box
with the text "four" will appear. Close the message box. The execution arrow will move to line 5. Press F11 or F10 again. A
message box with the text "five" will appear. Close the message box. Since there are additional lines still in the script,
QuickTest Professional will still be in run mode (though it will be idle). Click the Stop button to end test execution.
Are checkpoints available in Business Components
-------------------------------------------------------------------------------Solution: Single property checks are available with Business Components
Multiple property checkpoints are not available to Keyword-driven Business Components. Checkpoints are not
recommended for use within Scripted Components. To check object properties in a component, use a single property
check.
The Business Components have some built-in methods you can use to verify the values or other properties of the
various controls in your application.
To verify whether a specified object is enabled:
VerifyEnable(obj)
obj The test object
To verify the value of a specified object:
VerifyValue(obj, ExpectedValue)
obj The test object
ExpectedValue The expected value to be compared and verified during the test run. The format of the expected value
depends on the type of test object.
To verify the value of a specified property:
VerifyProperty(obj, PropertyName, ExpectedValue)
obj The test object
PropertyName The property name to check
ExpectedValue The expected value of the property
Note:
QuickTest Professional passes the test objects to the functions automatically, so you do not need to pass a value to the
first parameter when calling these functions.
When working with Business Process Testing 8.2.1 via TestDirector for Quality Center, there is no default list of available
object properties from which a single property checkpoint can be created. The property must be entered manually. An
enhancement request for a default list of properties has been submitted.
You can use the QuickTest Professional Object Spy or refer to the QuickTest Professional Object Model Reference
description for a list of properties you can reference. For example, if your control is a standard windows button, refer to
the Object Model Reference -> Standard Windows -> WinButton Object -> Properties -> WinButton Identification
Properties.
Each of the functions will return True if the expected condition is met.
Parameterizing components
1. Create the component.
2. Select the Parameters tab. Add the input/output parameters as needed.
Click <New>.
Enter a descriptive name in the Parameter name, and click <OK>. To make the input and output parameters easier to
identify, you may want to add "_in" or "_out" to the end of the parameter name. The new parameter will appear in the
relevant list.
Select the Value Type for the parameter.
For input parameters, enter the default value that should be used. The default value must correspond to the selected
value type.
In the Description column, add a description for the parameter.
3. Select the Automation tab. (If you are using BPT 8.x select the Steps tab.)
4. In the Keyword View, select the step to be parameterized.
5. Click on the "Configure the value" button in the Value cell. The "Value Configuration Options" dialog will appear.
6. Select the "Parameter" radio button and "Component parameter" in the combobox.
7. Select the desired component parameter in the Name combobox.
8. Repeat steps 4 through 7 for each input parameter.
9. Select the step that will generate the output parameter.
10. Click on the "Specify parameter for output" button in the Output cell. The "Output Options" dialog will appear.
11. Select "Component parameter" in the Output Types combobox.
12. Select the desired component output parameter in the Name combobox.
13. Repeat steps 9 through 12 for each output parameter.
14. If the component should be iterated, make sure the "Allow Iterations" option on the Details tab is set to Y.
Data Table
Two Types of data tables
Usage:
If we change any thing in the Data Table at Run-Time the data is changed only in the run-time data table. The run-time data
table is accessible only through then test result. The run-time data table can also be exported using DataTable.Export or
DataTable.ExportSheet
How can i save the changes to my DataTable in the test itself?
Well QTP does not allow anything for saving the run time changes to the actual data sheet. The only work around is
to share the
spreadsheet and then access it using the Excel COM Api's.
Well you can't do it normally but you can use Excel COM API's do the same. Below code will explain some expects
of Excel COM APIs
code:
Set xlApp=Createobject("Excel.Application")
set xlWorkBook=xlApp.workbooks.add
set xlWorkSheet=xlWorkbook.worksheet.add
SMART Identification
Smart Identification is nothing but an algorithm used by QTP when it is not able to recognize one of the object. A very
generic example as per the QTP manual would be, A photograph of a 8 year old girl and boy and QTP records identification
properties of that girl when she was 8, now when both are 10 years old then QTP would not be able to recognize the girl.
But there is something that is still the same, that is there is only one girl in the photograph. So it kind of PI (Programmed
intelligence) not AI.
When should i use SMART Identification?
Something that people don't think about too much. But the thing is that you should disable SI while creating your
test cases. So that you are able to recognize the objects that are dynamic or inconsistent in their properties. When
the script has been created, the SI should be enabled, so that the script does not fail in case of small changes. But
the developer of the script should always check for the test results to verify if the SI feature was used to identify a
object or not. Sometimes SI needs to be disabled for particular objects in the OR, this is advisable when you use
SetTOProperty to change any of the TO properties of an object and especially ordinal identifiers like index, location
and creationtime.
Descriptive Programming
Descriptive programming is nothing but a technique using which operations can be performed on the AUT object
which are not present in the OR. For more details refer to http://bondofus.tripod.com/QTP/DP_in_QTP.doc (right
click and use save as...)
Recovery Scenarios
What is a Recovery Scenario?
Recovery scenario gives you an option to take some action for recovering from a fatal error in the test. The error
could range in from occasional to typical errors. Occasional error would be like "Out of paper" popup error while
printing something and typical errors would be like "object is disabled" or "object not found". A test case have more
then one scenario associated with it and also have the priority or order in which it should be checked.
Trigger: Trigger is nothing but the cause for initiating the recovery scenario. It could be any popup window, any test
error, particular state of an object or any application error.
Action: Action defines what needs to be done if scenario has been triggered. It can consist of a mouse/keyboard
event, close application, call a recovery function defined in library file or restart windows. You can have a series of
all the specified actions.
Post-recovery operation: Basically defined what need to be done after the recovery action has been taken. It could
be to repeat the step, move to next step etc....
Recovery scenarios are used when you cannot predict at what step the error can occur or when you know that error
won't occur in your QTP script but could occur in the world outside QTP, again the example would be "out of paper",
as this error is caused by printer device driver. "On error resume next" should be used when you know if an error is
expected and dont want to raise it, you may want to have different actions depending upon the error that occurred.
Use err.number & err.description to get more details about the error.
Library files are files containing normal VBScript code. The file can contain function, sub procedure, classes etc....
You can also use execute file function to include a file at run-time also. To associate a library file with your script go
to Test->Settings... and add your library file to resources tab.
When to associate a library file with a test and when to use execute file?
When we associate a library file with the test, then all the functions within that library are available to all the actions
present in the test. But when we use Executefile function to load a library file, then the function are available in the
action that called executefile. By associated a library to a test we share variables across action (global variables
basically), using association also makes it possible to execute code as soon as the script runs because while
loading the script on startup QTP executes all the code on the global scope. We can use executefile in a library file
associated with the test to load dynamic files and they will be available to all the actions in the test.
Add-ins
Test and Run-time Object
What is the difference between Test Objects and Run Time Objects ?
Test objects are basic and generic objects that QTP recognize. Run time object means the actual object to which a
test object maps.
Yes. You can use SetTOProperty to change the test object properties. It is recommended that you switch off the
Smart Identification for the object on which you use SetTOProperty function.
No (but Yes also). You can use GetROProperty("outerText") to get the outerText of a object but there is no function
like SetROProperty to change this property. But you can use WebElement().object.outerText="Something" to
change the property.
Action is a thing specific to QTP while functions are a generic thing which is a feature of VB Scripting. Action can
have a object repository associated with it while a function can't. A function is just lines of code with some/none
parameters and a single return value while an action can have more than one output parameters.
Well answer depends on the scenario. If you want to use the OR feature then you have to go for Action only. If the
functionality is not about any automation script i.e. a function like getting a string between to specific characters,
now this is something not specific to QTP and can be done on pure VB Script, so this should be done in a function
and not an action. Code specific to QTP can also be put into an function using DP. Decision of using function/action
depends on what any one would be comfortable using in a given situation.
Checkpoint & Output value
What is checkpoint?
Checkpoint is basically a point in the test which validates for truthfulness of a specific things in the AUT. There are
different types of checkpoints depending on the type of data that needs to be tested in the AUT. It can be text,
image/bitmap, attributes, XML etc....
Checkpoint only checks for the specific attribute of an object in AUT while Output value can output those attributes
value to a column in data table.
My test fails due to checkpoint failing, Can i validate a checkpoint without my test failing due to checpoint failure?
code:
Environment
How can i import environment from a file on disk
Environment.LoadFromFile "C:\Env.xml"
When we use Environment("Param1").value then QTP expects the environment variable to be already defined. But
when we use Environment.value("Param1") then QTP will create a new internal environment variable if it does not
exists already. So to be sure that variable exist in the environment try using Environment("Param1").value.
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=<UID>;PWD=<PWD>"
objRecordset.CursorLocation = adUseClient
objRecordset.CursorType = adopenstatic
objRecordset.LockType = adlockoptimistic
ObjRecordset.Source="select field1,field2 from testTable"
ObjRecordset.ActiveConnection=ObjConnection
ObjRecordset.Open 'This will execute your Query
If ObjRecordset.recordcount>0 then
Field1 = ObjRecordset("Field1").Value
Field2 = ObjRecordset("Field2").Value
End if
How to create dialog box with option in QTP ?
res = msgbox ("Is it your first run (Yes/No) ? ", vbYesNo,"First run Indicator")
If res = 6 Then ' 6 = Yes ; 7 = No
some code ....
end if
Dim Sample
Sample = InputBox ("Checking", 65, "InputBox Sample")