Blank Screens through CaptureBitmap method can be encountered if the system gets locked when the automation scripts are running. To avoid this, it can be assured that the system doesn't get locked when the scripts are getting executed.
This can be done by calling the following function through the automation scripts:-
Public Function AntiSleep()
Dim iter
randomize
iter = randomNumber(0, 100)
Dim objDeviceReplay
Set objDeviceReplay = CreateObject("Mercury.DeviceReplay")
objDeviceReplay.MouseMove iter,300
Set objDeviceReplay = Nothing
End Function
The above function can be called in an automation script using QTP, and the script can be scheduled to run through control panel recursively.
What is ReplayType?
ReplayType is QTP Web Add-in setting. It can be used to change how the events are replayed on the browser. There are two modes of ReplayType
Events (1) – Replay of events using the Browser methods (something similar to DOM).
Mouse (2) – Replay of events using the mouse and keyboard simulation.
When to change ReplayType?
Use of ReplayType can be best explained by a below example. In below sample textbox we need to type in any value and see that the button gets enabled when there some text in the textbox and disabled when there is not text. Click on the button will display the values inside the textbox.
Scenario #1
Type in textbox and enable the button:
Now when we record using QTP on this page we would get the below code
The input text box has a handler for onkeyup event. Now with ReplayType as 1 (events) QTP just goes and sets the value of textbox which means non of the events get fired. Now there are two possible solutions for the same. We will look at each of them one by one Solution #1
Firing the handled event manually using FireEvent. In this approach we need to look into the HTML and see which event has a handler and fire the same after changing the value of the textbox
Browser("").Page("ReplayType").WebButton("Type and enable me").Click
Solution #2
Changing ReplayType to 2 (Mouse) will instruct QTP to replay the Set method using Keyboard and mouse simulation. This would simulate a actual user typing into the browser
Browser("").Page("ReplayType").WebButton("Type and enable me").Click
Setting.WebPackage("ReplayType")=1'Events
We saw two of the few possible solutions. Which one should be used then? IMO we should first go for Solution #1 and if that does not work then for Solution #2. The reason behind that opinion is that ReplayType=2 means that your workstation needs unlocked when QTP replays the script.
Scenario #2
I won’t demonstrate the 2nd scenario but would just give overview of the same. For some links which opens popups, when clicked manually popup would open. But when we do the same thing through QTP it IE popup blocker would show a popup blocked message. IE popup blocker is said to be smart enough to determine if a user clicked a link or it was done through code and based on the same the popup is blocked or shown. Changing ReplayType to 2 (Mouse) would simulate a user click and not give the popup bar.
Working with wbfGrid:-
1. Mark .Net Add-in as Enabled.
2. Record a test with some operations on a WebTable.
3. The web-table is recorded as a wbfgrid.
4. Disable .Net Add-in.
5. WbfGrid won't be recognized, only WebTables can be recognized now.
So, for working with wbfGrid .Net add-in must be enabled.
Arrays v/s Collections in QTP:-
1. Arrays are of fixed size.
Dim arr(3)
arr = Array(3,1,5)
1. Collections are growable in size.
Set col = Browser("").Page("").WebEdit("").GetToProperties()
2. For memory usage, Collections are recommended to use instead of Arrays. Because a Collection object uses less memory than an array.
3. Performance wise, arrays are preferred over collections.
4. Arrays can hold basic data types. Whereas, collections can hold only objects.
Properties of a collection:-
col.Count
col(i).Name
col(i).Value
col(i).RegularExpression
Methods of an array:-
UBound(arr); LBound(arr)
Function hoverMouse(objName)
Set obj = findObject(objName) 'findObject is a function to return a given object.
Set dRep = CreateObject("Mercury.DeviceReplay")
x = obj.GetROProperty("abs_x")
y = obj.GetROProperty("abs_y")
dRep.MouseMove x,y
Set dRep = Nothing
End Function
abs_x - absolute value of x coordinate
x - coordinate x relative to the parent object.
QTP shows that an object exists but it is not visible on the screen. Then how to prove whether object exists or not.
Function isHiddenObject(objName)
Set obj = findObject(objName)
w = obj.getROProperty("width")
h = obj.getROProperty("height")
x = obj.getROProperty("x")
y = obj.getROProperty("y")
If w = 0 and h = 0 and x = 0 and y = 0 Then
isHiddenObject = True
End If
End Function
1. Your experience in QTP, that is, projects worked on.
2. Framework used.
3. Functions in string handling.
4. Order in which QTP uses different methods to recognize an object. - DVSO, that is, Descriptive Properties -> Visual Relational Identifier -> Smart Identification -> Ordinal Identifier.
5. If QTP is unable to recognize object thru DVSO then how will the object be recognized. - thru descriptive prog., virtual objects etc.
6. Explain SetTOProperty, GetTOProperty.
7. Distinguish between Output Value and Checkpoints.
8. How to use virtual objects.
9. Steps to open a given browser at a particular url.
10. How to write a SQL connection thru QTP.
11. DNL and DNL less connection.
12. Difference between Absolute Path and Relative Path.
13. If an object is not visible on web page but QTP says it exists then how to make sure that it exists.
- should be familiar with Data Driven, Keyword and Hybrid Frameworks.
Manual Testing
1. 6 phases in Bug Life Cycle.
2. Difference between - Smoke Testing, end-to-end testing, and Sanity Testing.
3. What is a deferred defect.
4. What is RTM. - Requirements Traceability Matrix.
> “Output Values” are used to retrieve values for later use and so it will retrieve the property values you select and place them in the datatable for you. > Checkpoints are primarily used to see if the property values of an object have changed from an anticipated value, or state in the application. Like: has my button moved, is the edit field enabled or disabled, what is the current default value in the edit field, etc. In addition, checkpoints have the ability to use parameters in order to handle dynamic situations so you don’t have to hardcode a value in the checkpoint.