Overview

Overview

Welcome to QTP interview questions

Hello software Quality engineers. Welcome to our Software testing world and common QTP(Quick test pro) related technical issues, interview questions etc. . Over 2 years, I am trying to update all possible interview questions in testing area of QTP. With your continuous comments on the topics and suggestions, we are growing day by day.

Showing posts with label mercury QTP. Show all posts
Showing posts with label mercury QTP. Show all posts

Wednesday, December 19, 2007

What is the difference between Image check point and Bitmap check point?

By using image check point we can check the properties of an image whether they are matching with the recorded properties or not.
These properties includes image file path, href links, owner of the image tec.. if these properties are not same as the original recorded version, then the script fails.
By inserting a standard check point we can insert this image check point on any image in the application. Image check points are normally supported by web based applications.

On other hand, Bitmap check points consider a specific selected area as a bitmap image after capturing that area as a bitmap image. This is normally used for a variable webpage. i.e for a webpage with a tendency of varying its page contents in terms of its displayed objects in terms of length , X Y coordinates etc. For example in a webpage the welcome note is 4 lines initially when you first recorded the webpage. But after few days while running the same script it will fail because the welcome note has been changed to 8 lines instead of 4 lines initially. By using bitmap check points we can capture this issues.

How to connect to a database from QTP?

Use the below code for connecting a database from QTP.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=;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

What is the difference between Check points and Output values ?

Check points are normally used to check the screen values, screen object properties to find out if there are any changes from the recorded version.

Where as output values are used to check the properties of the objects and these properties will be written to the data table columns in the sctipt.

Use the below code to validate if the checkpoint is passed or failed:
chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))if chk_PassFail then MsgBox "Check Point passed"else MsgBox "Check Point failed"end if

Use the below code to stop any exceptions that will raise due to check point failure.Reporter.Filter = rfDisableAll 'Disables all the reporting stuff
chk_PassFail = Browser(...).Page(...).WebEdit(...).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

What is the use of Actions and Functions in QTP? What do you know about Actions, functions in QTP?

Actions are specific to QTP. Normally a single or combination of multiple actions make a QTP script. Actions can associate with OR (object repository).

Functions are a piece of VB script code that has a variables and after execution will produce a return value that will be passed to the script back for further usage. Functionas can not associate with OR.

When we need to add some functionality to qtp script then we go for functions and call them in scripts.

What do know by ADD-ins in QTP? Properties of Test object? Runtime object?

Test objects are the one that will be recognized by QTP, where as Runtime objects are the actual objects that the test objects will be linked to.

SetTOProperty() function is used to change the properties of a test object.
Similarly GetROProperty(outer text) is used to get the outer text of object. Or you can use,
Webelement().object.outerText = “asasasasssa”.

How do you deal with Library files (VB script files)? How do you add library files in a test ?

How do you deal with Library files (VB script files)? How do you add library files in a test ?

Library functions are nothing but common vb script coding snippets . This group of small piece of codes are made as functions , procedures, classes, methods etc.. and they are stored in libraries with a meaning full name.

In Script-Testing, we can associate a library function to a test even at run time.

When we associate a library file in a test, then all the related functions with in the library are available to all the actions of the script. Where as if you use an executable function to call the library, then only that particular action from where we are calling the executable function will have permission to use the library functions.

Keywords:
QTP, library functions, library files, vbscript functions, vbsctipt codes, executable files, vb script code, QTP, mercury QTP, Functional testing, testing tools

What do you know about Recovery scenario? What are the components of Recovery scenario? How do you use recovery scenario? When and where to use Recove

What do you know about Recovery scenario? What are the components of Recovery scenario? How do you use recovery scenario? When and where to use Recovery scenario?

As its name indicates, Recovery scenario gives us an option to recover from unexpected errors in QTP. It will recover from any type of errors whether it is a fatal error like object not found, path not found, system error etc… or a small error like pop up error, out of paper from printer etc…

The main components or steps that exist in a recovery scenario are:
Trigger:
A trigger is an even that initiates the recovery scenario to start working. These events can be fired by any action like ‘A sudden pop up’, ‘application error’, or change in the property of any object etc…

Action:
Action is a single or series of steps to be followed after the recovery scenario is triggered by an event. What to be done after recovery scenario is triggered? Any key board event, mouse event, calling any function to execute etc…

After these actions are executed, we can also set what to be done after this? Got o next executable step and go ahead from there? Etc…

In normal cases, recovery scenario is used when you are not able to find out the root of the error or place of the error. Because some errors may raise outside the QTP like ‘out of paper’ etc..
But if you know the line exactly where an error may raise in QTP, then you can use ‘Error resume next’ function instead of recovery scenario.

What is Smart Identification? What is its use in QTP?

Smart identification is normally used when a particular object in the script is not found or, if the the object properties have been changed over a period of time and QTP not able to recognize the object.

Smart Identification is a internal algorithm used by QTP. Smart identification feature is being enabled when an object is not recognized by QTP.

Smart identification should not be enabled during recording the script. You have to disable this feature. Once after the script is generated, then you can enable the smart identification feature.

The secret behind the smart identification is: Even though the object properties have been changed during a period of time, there will be some common points that still exist in both the versions of the object. Smart Identification catches that common property and recognizes the object. Smart identification is an important feature in QTP.

Did you write any custom function in QTP?

Yes, I have written a custom function in QTP for editing the Data table row colors.
Below is the code for this using Excel COM api’s.
Set xlApp=Createobject("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

How can I find if a parameter is there in a global sheet?

Val = DataTable(“parameter name”, dtGlobalSheet)
If err.number <> 0 then
Print ‘parameter not exist’
Else
Print ‘parameter exists’
Endif.

DataTable() function returns a value in integer into err.number.