Rehearsal of QTP in 1 Hr: Interview Questions 141 – 150
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. 141: How can we get the no. of descriptions defined in a collection?
By using obj_ChkDesc.Count
<<<<<< =================== >>>>>>
Q. 142: How can you remove a description from the collection?
obj_ChkDesc.remove “html tag” �would delete the html tag property from the collection
<<<<<< =================== >>>>>>
Q. 143: How can you check if property exists or not in the collection?
The answer is that it�s not possible. Reason being whenever we try to access a property, which is not, defined its automatically added to the collection.
The only way to determine is to check its value that is use a if statement “if obj_ChkDesc(“html tag”).value = empty then”.
<<<<<< =================== >>>>>>
Q. 144: How to browse through all the properties of a properties collection?
There are two ways to do it
1st Method:
For each desc in obj_ChkDesc
Name=desc.Name
Value=desc.Value
RE = desc.regularexpression
Next
2nd Method:
For i=0 to obj_ChkDesc.count – 1
Name= obj_ChkDesc(i).Name
Value= obj_ChkDesc(i).Value
RE = obj_ChkDesc(i).regularexpression
Next
<<<<<< =================== >>>>>>
Q. 145: How can you describe an object by giving the description in the form of the string arguments?
You can describe an object directly in a statement by specifying property:=value pairs describing the object instead of specifying an object�s name.
The general syntax is:
TestObject(“PropertyName1:=PropertyValue1”, “…” , “PropertyNameX:=PropertyValueX”)
TestObject�the test object class could be WebEdit, WebRadioGroup etc�.
PropertyName:=PropertyValue�the test object property and its value.
Each property:=value pair should be separated by commas and quotation marks.
You can enter a variable name as the property value if you want to find an object based on property values you retrieve during a run session.
Consider the following HTML Code:
INPUT type=”textbox” name=”txt_Name”
INPUT type=”radio” name=”txt_Name”
Now to refer to the textbox the statement would be as given below
Browser(“Browser”).Page(“Page”).WebEdit(“Name:=txt_Name”,”html tag:=INPUT”).set “Test”
And to refer to the radio button the statement would be as given below
Browser(“Browser”).Page(“Page”).WebRadioGroup(“Name:=txt_Name”,”html tag:=INPUT”).set “Test”
If we refer to them as a web element then we will have to distinguish between the two using the index property
Browser(“Browser”).Page(“Page”).WebElement(“Name:=txt_Name”,”html tag:=INPUT”,”Index:=0″).set “Test” � Refers to the textbox Browser(“Browser”).Page(“Page”).WebElement(“Name:=txt_Name”,”html tag:=INPUT”,”Index:=1″).set “Test” � Refers to the radio button
<<<<<< =================== >>>>>>
Q. 146: How can I check if a parameter exists in the Data Table or not?
The best way would be to use the following code:
on error resume next
val=DataTable(“ParamName”,dtGlobalSheet)
if err.number<> 0 then
‘Parameter does not exist
else
‘Parameter exists
end if
<<<<<< =================== >>>>>>
Q. 147: How can I make some rows colored in the data table?
You can’t do it normally but you can use Excel COM API’s for this purpose.
Following code explains some expects of Excel COM APIs
code:
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
<<<<<< =================== >>>>>>
Q. 148: What is Smart Identification? And when do you use it?
Smart Identification is nothing but an algorithm used by QTP when it is not able to recognize one of the objects.
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 is a kind of PI (Programmed intelligence) not AI.
When should I use SMART Identification?
This is 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.
<<<<<< =================== >>>>>>
Q. 149: How can you associate a procedure to a test object class?
By the use of statement: RegisterUserFunc
<<<<<< =================== >>>>>>
Q. 150: 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.
Continue to Next Set of QTP Rehearsal Questions 151 – 160
An expert on R&D, Online Training and Publishing. He is M.Tech. (Honours) and is a part of the STG team since inception.