Rehearsal of QTP in 1 Hr: Interview Questions 161 – 170
While appearing in an interview for a position on HP QuickTest Professional, do a quick rehearsal of your knowledge on this tool.
Here is a collection of 180 short questions, QTP Managers commonly use while interviewing new aspirants for their organization.
The entire rehearsal of these questions can take less than an hour.
Set of Ten Questions
Q. 161: How do you know the no of links in a web page?
Answer -1: By Page Check point,
Answer-2: By following set of statements:
Set PageDesc = Description.Create
PageDesc(“Class
Name”).Value = “Link”Set Pages = Browser(“Mercury Interactive”).Page(“Mercury Interactive”).ChildObjects(PageDesc)
Number_of_pages = Pages.Count
If Number_of_pages = 0 Then
Reporter.ReportEvent micDone, “No links was found in the web page, “”
End If
<<<<<< =================== >>>>>>
Q. 162: How can I check if a checkpoint passes or not?
This can be done by the following code.
Code:
chk_PassFail = Browser(…).Page(…).WebEdit(…).Check (Checkpoint(“Check1”))
if chk_PassFail then
MsgBox “Check Point passed”
else
MsgBox “Check Point failed”
end if
<<<<<< =================== >>>>>>
Q. 163: My test fails due to checkpoint failing. Can I validate a checkpoint without my test failing due to checkpoint failure?
This can be done by the following code.
Code:
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
<<<<<< =================== >>>>>>
Q. 164: How can I import an environment from a file on disk?
Environment.LoadFromFile “C:Env.xml”
<<<<<< =================== >>>>>>
Q. 165: How can I check if an environment variable exist or not?
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.
<<<<<< =================== >>>>>>
Q. 166: How to connect to a database?
This can be done by the following code.
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=;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
<<<<<< =================== >>>>>>
Q. 167:How do you create a Template for every Actions?
Write the template script as “ActionTemplate.mst” in DAT folder of QTP Installation
<<<<<< =================== >>>>>>
Q. 168:Test –>Settings –> Run tab belongs to which sheet:
Global Data sheet
<<<<<< =================== >>>>>>
Q. 169:What is the first step in editing an object in the object repository?
Enable Editing
<<<<<< =================== >>>>>>
Q. 170:When using recovery scenario wizard, the first phase is to specify?
Triggered Events
Continue to Next Set of QTP Rehearsal Questions 171 – 180
An expert on R&D, Online Training and Publishing. He is M.Tech. (Honours) and is a part of the STG team since inception.