Вы находитесь на странице: 1из 11

Full form of QTP?

Quick Test Professional

What’s the QTP?


QTP is Mercury Interactive Functional Testing Tool.

What’s the basic concept of QTP?


QTP is based on two concepts-

• Recording

• Playback

Which scripting language used by QTP?


QTP using VB scripting.

How many types of recording facility are available in QTP?


QTP provides three types of recording methods-

• Context Recording (Normal)

• Analog Recording

• Low Level Recording

How many types of Parameters are available in QTP?


QTP provides three types of Parameter-

• Method Argument

• Data Driven

• Dynamic

What’s the QTP testing process?


QTP testing process consist of seven steps-

• Preparing to recoding

• Recording

• Enhancing your script

• Debugging
• Run

• Analyze

• Report Defects

What’s the Active Screen?


It provides the snapshots of your application as it appeared when you performed a certain
steps during recording session.

What’s the Test Pane?


Test Pane contains Tree View and Expert View tabs.

What’s Data Table?


It assists to you about parameterzing the test.

What’s the Test Tree?


It provides graphical representation of your operations which you have performed with
your application.

Which all environment QTP supports?

ERP/ CRM
Java/ J2EE
VB, .NET
Multimedia, XML
Web Objects, ActiveX controls
SAP, Oracle, Siebel, PeopleSoft
Web Services, Terminal Emulator
IE, NN, AOL

How can you view the Test Tree?

The Test Tree is displayed through Tree View tab.

What’s the Expert View?

Expert View display the Test Script.

Which keyword used for Normal Recording?

F3

Which keyword used for run the test script?

F5
Which keyword used for stop the recording?

F4

Which keyword used for Analog Recording?

Ctrl+Shift+F4

Which keyword used for Low Level Recording?

Ctrl+Shift+F3

Which keyword used for switch between Tree View and Expert View?

Ctrl +Tab

Note:

> QTP records each step you perform and generates a test tree and test script.

> QTP records in normal recording mode.

> If you are creating a test on web object, you can record your test on one browser and
run it on another browser.

> Analog Recording and Low Level Recording require more disk sapce than normal
recording mode.

What’s the Transaction?

You can measure how long it takes to run a section of your test by defining transactions.

Where you can view the results of the checkpoint?

You can view the results of the checkpoints in the Test Result Window.

Note:

If you want to retrieve the return value of a checkpoint (a Boolean value that indicates
whether the checkpoint passed or failed) you must add parentheses around the checkpoint
argument in the statement in the Expert View.

What’s the Standard Checkpoint?

Standard Checkpoints checks the property value of an object in your application or web
page.
Which environments are supported by Standard Checkpoint?

Standard Checkpoint is supported for all add-in environments.

What’s the Image Checkpoint?

Image Checkpoint checks the value of an image in your application or web page.

Which environments are supported by Image Checkpoint?

Image Checkpoint is supported only Web environment.

What’s the Bitmap Checkpoint?

Bitmap Checkpoint checks the bitmap images in your web page or application.

Which environment is supported by Bitmap Checkpoints?

Bitmap checkpoints are supported all add-in environment.

What are the Table Checkpoints?

Table Checkpoint checks the information with in a table.

Which environments are supported by Table Checkpoint?

Table Checkpoints are supported only ActiveX environment.

What’s the Text Checkpoint?

Text Checkpoint checks that a test string is displayed in the appropriate place in your
application or on web page.

Which environments are supported by Test Checkpoint?

Text Checkpoint are supported all add-in environments

How to use automation object to load the library files in QTP. I tried to use
this stmt" set A
How to use automation object to load the library files in QTP. I tried to use this stmt"
set App = createobject
("Quicktest.Application") App. Test. Settings. Resources.Libraries.Add
("F:QTPrepository.vbs"),1 ".could u pls help how to add it by script itself? what is
executefile concept? is it workaround to my question?
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable

Dim qtLibraries 'As QuickTest.TestLibraries ' Declare a test's libraries collection


variable

Dim lngPosition

' Open QuickTest

Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object

qtApp.Launch ' Launch QuickTest

qtApp.Visible = True ' Set QuickTest to be visible

' Open a test and get its libraries collection

qtApp.Open "C:\Test1", False, False ' Open a test

Set qtLibraries = qtApp.Test.Settings.Resources.Libraries ' Get the libraries collection


object

' Add Utilities.vbs if it's not in the collection

If qtLibraries.Find("C:\sai1.vbs") = -1 Then ' If the library cannot be found in the


collection

qtLibraries.Add "C:\sai1.vbs", 1 ' Add the library to the collection

End If

when ever you want to add library files(.VBS) files to the script, use th following
function.

Execute file(" Path of file ")

the above function load the VBS file to your script and you can use the fucntions in
VBS file using

Call Function name (arg list)

What is Smart Identification in QTP

Any property of test object is not matching with run time object property, it will write
an warning to result and execute rest of the steps.
2. Generally object identification is used for to identify the GUI objects in the screen.
When u recording the script automatically the object identifier records the objects in
the screen (in win runner we had GUI map configuration).

But, this smart identification will be identified the objects. Whether this objects is
developed with same technology or not.

Eg: Application is developed in JAVA but in places we used some Microsoft controls.
Where generally the QTP will have to recognize the components at that time smart
identification will identify the objects.

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

4.

When Quickest uses the recorded description to identify an object, it searches for an
object that matches every one of the property values in the description. In most
cases, this description is the simplest way to identify the object and unless the main
properties of the object change, this method will work.

If Quickest is unable to find any object that matches the recorded object description,
or if it finds more than one object that fits the description, then Quickest ignores the
recorded description, and uses the Smart Identification mechanism to try to identify
the object.

5. While the Smart Identification mechanism is more complex, it is more flexible,


and thus, if configured logically, a Smart Identification definition can probably help
Quick test identify an object, if it is present, even when the recorded description fails

QTP 8.2 FAQ, Tips & Tricks


Well this post is about tips on various topics. I will try to cover as many as i have in mind and would try
to summarize the tips that people have given on the forum (including me )
Data Table
Two Types of data tables
„X Global data sheet: Accessible to all the actions
„X Local data sheet: Accessible to the associated action only
Usage:
„X Data Table("Column Name", dtGlobalSheet) for Global data sheet
„X Data Table("Column Name",dtLocalSheet) for Local data sheet
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 Data
Table.Export Sheet
How can i save the changes to my Data Table in the test itself?
„X 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 Ape’s.
How can i check if a parameter exists in Data Table or not?
„X The best way would be to use the below code:
code:
________________________________________
on error resume next
Val=Data Table("Param Name", dtGlobalSheet)
if err. Number<> 0 then
'Parameter does not exist
else
'Parameter exists
end if
________________________________________
How can i make some rows colored in the data table?
„X 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=Create object ("Excel. Application")

set xlWorkBook = xlApp.workbooks.add

set xlWorkSheet = xlWorkbook.worksheet.add

xlWorkSheet.Range ("A1:B10").interior.colorindex = 34 'Change the color of the cells

xlWorkSheet.Range ("A1:A10").value="text" 'Will set values of all 10 rows to "text"

xlWorkSheet.Cells(1,1).value="Text" 'Will set the value of first row and first col

rowsCount= xlWorkSheet.Evaluate ("COUNTA(A:A)") 'Will count the # of rows which have non blank

Value in the column A

colsCount = xlWorkSheet.Evaluate("COUNTA(1:1)") 'Will count the # of non blank columns in 1st row

xlWorkbook.SaveAs "C:\Test.xls"

xlWorkBook.Close

Set xlWorkSheet=Nothing

Set xlWorkBook=Nothing

set xlApp=Nothing
________________________________________
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?
„X 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 creation time.


Descriptive Programming
„X 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?
„X 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?
„X 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.
„X 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.
„X 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?
„X 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 don’t want to raise it,
you may want to have different actions
Depending upon the error that occurred. Use errs. 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?
„X 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?
„X 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 Execute file function to load a library file, then the function are available in the action
that called execute file. 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 execute file 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?
„X Test objects are basic and generic objects that QTP recognize. Run time object means the actual
object to which a test objects maps.
Can i change properties of a test object
„X 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?
„X No (but Yes also). You can use GetROProperty("outerText") to get the outer Text 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?
„X 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?
„X 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?
„X 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....
What's the difference between a checkpoint and output value?
„X 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.
How can i check if a checkpoint passes or not?
code:
________________________________________
chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))
if chk_PassFail then
MsgBox "Check Point passed"
else
MsgBox "Check Point failed"
end if
________________________________________
My test fails due to checkpoint failing, Can i validate a checkpoint without my test failing due to
checpoint failure?
code:
________________________________________
Reporter. Filter = rfDisableAll 'Disables all the reporting stuff
chk_PassFail = Browser(...).Page(...).Web Edit(...).Check (Checkpoint("Check1"))
Reporter.Filter = rfEnableAll 'Enable all the reporting stuff
if chk_PassFail then
MsgBox "Check Point passed"
else
MsgBox "Check Point failed"
end if
________________________________________
Environment
How can i import environment from a file on disk
„X Environment.LoadFromFile "C:\Env.xml"

How can i check if a environment variable exist or not?

„X 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.

How to connect to a database?


code:
________________________________________
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

Вам также может понравиться