Saturday, 13 June 2015

QTP - 30 - Optional step in QTP !

As the name suggests the "Optional step" doesn't needs to be necessarily executed during run session. A step when declared optional is not mandatory to be executed. If the corresponding GUI object is present, QTP performs the operation on it. If the GUI object is not present, QTP bypasses the optional step and proceeds to execute the next step.
To set a step as optional in keyword view right click on the step and select Optional Step.
Alternatively, you can directly write the keyword "OptionalStep" preceding a statement to make it optional

QTP - 29 - Difference between check point and output value ?

Check point is a verification point that compares a current value for a specified property with the expected value for that property. Based on this comparison, it will generate a PASS or FAIL status. The value of an object is saved during recording against which the value is compared while playback.Checkpoints has PASS/FAIL status.

An output value is a value captured during the test run and can be stored in a specified location like the  Datable or even a variable.This option is used to get the runtime output values of the application objects either Text values or Property Values or Database values. Output values enable to view the values that the application takes during run time.When paramaterised, the values change for each iteration.Thus by creating output values, we can capture the values that the application takes for each run and output them to the data table.

QTP - 28 - Why we not only use Odinal Identifiers if they can uniquely identify the objects ?

We can't just use Ordinal Identifiers to identify all the objects. There are few limitations of them :

(1) If accidently or willingly the position of the object is changed then the Ordinal Identifier will not work.

(2) If two objects are overlapped on each other than location based object recognition will fail.

(3) If only index based recognition is used your script will work but script execution time will increase.

QTP - 27 - Few more things to know :

- Dictionary objects and Environvent variables are case sensitive.

- QTP runs only on window environment.

- User can toggle between LOR and SOR any time
Test->Settings->Resources

- Scripts can be written in : Visual Basic (VB), XML, JavaScript, Java, HTML

- Smart Identification may be used to identify dynamic objects.

- Step-generator is used for inbuilt scripting

- Using Transaction we can measure the time in execution.

- UFT has the feature of insight recording

- QTP/AFT can be configured externally through AOM

- We can't use object spy on Virtual objects

- We can record scripts on remote machine but we can't perform any action on remote browser like citrix

- QTP batch testing tool may be used to run multiple scripts in one go.



Friday, 12 June 2015

QTP - 26 - TOM

It is a collection of objects types or classes that are used to represent objects in application. A test object class comprises of a list of properties that can uniquely identify the object. Basically,object means any data in application that supports methods and properties. QTP support two types of  objects as,


Test Object(TO) :- QTP creates an object during recording mode that correspond to object in application called as Test Object.The properties of objects are stored in in Object Repository that are used to identify object during run session.

Run Time Object(RO) :- The object that QTP uses to identify actual object in application during run session is Run Time Object. QTP uses the properties stored in object repository to identify actual object in application during run session.
You can add objects in object repository simply by recording events in application or by manually in object repository.

Both TO and RO supports various properties and methods.These properties can be retrieved using GetRO property and can be set using SetTO property.
Use Object Spy to view properties and methods supported by objects.


The properties of each test object is created and maintained by Q.T.P while the properties of run-time object s are created and maintained by the test object architect.

Methods and Properties  :

- Each method/operation that we perform on test object is recorded as separate step in Q.T.P.

- Each properties of object are captured from test objects while recording. QTP uses these properties to uniquely identify objects during runtime.

- Property of any TO can be changed , we can use setTOProperties to change the property of any TO.

- Object Spy is used to see the hierarchy of any TO


Object Hierarchy in QTP:-

its Very important to know the hierarchy of any object to uniquely identify it and perform any operation on it.

If object is on simple page then Hierarchy will be as shown:-


In the expert view,you can view your statement as:-

Browser(" ").Page(" ").WebList(" ").Select" "

If object is on simple page having frame then Hierarchy will be as shown:-




In the expert view,you can view your statement as:-

Browser(" ").Page(" ").Frame("MainFrame").WebElement(" ").click

If object is on Window then Hierarchy will be as shown:-














In the expert view,you can view your statement as:-

Browser(" ").Window(" ").Page(" ").Frame("ebRealModal").WebElement(" ").click



If object is on Window which is on other window then Hierarchy will be as shown:-

In the expert view,you can view your statement as:-

Browser(" ").Window(" ").Window(" ").Page(" ").Frame("ebRealModal").WebElement(").click

Wednesday, 10 June 2015

QTP - 25 - What is Synchronization?

Synchronization point is the time interface between Tool and Application under test. Synchronization point is a feature to specify delay time between one step and another of the test script.

Method 1: WaitProperty
WaitProperty is a method that takes the property name, Value and Timeout value as input to perform the sync. It is a dynamic wait and hence this option is encouraged.

Eg :
obj.Link("Google").WaitProperty "text", "Browse",25000

Method 2: Exist
Exist is a method that takes the Timeout value as input to perform the sync. Again it is a dynamic wait and hence this option is encouraged.

Eg : obj.Link("Google").Exist(30)

Method 3: Wait
Wait is a hardcoded or static sync point which waits independent of the event happened or NOT. Hence usage of Wait is discouraged and can be used for shorter wait time such as 1 or 2 seconds.

Eg : wait(30)

Wait() statement without specifying the seconds will make QTP wait up to maximum time, even though operations is completed.

Method 4: Sync Method
Sync Method can be used only for web applications where there is always a lag between page loads.

Eg : Browser("Math Calculator").Sync

Method 5 : Default Synchronization:
When user hasn't used any of the above sync methods, still QTP has inbuild Object synchronization timeout which can be adjusted by the user.

Navigate to "File" >> "Settings" >> Run Tab >> Object Synchronization Time out. Here we can give the time we want QTP to wait for.

QTP - 24 - Associating library to QTP :

Based on the type of framework you are using, you can use any of the following methods to associate function libraries to your QTP Script -

1) By using ‘File > Settings > Resources > Associate Function Library’ option in QTP.
This is the most common method used to associate a function library to a test case. To use this method, select File > Settings option from the Menu bar. This will display the ‘Test Settings’ window. Click on Resources from the left hand side pane. From the right hand side pane, click on the ‘+’ button and select the function library that needs to be associated with the test case.

2) By using Automation Object Model (AOM).

QTP AOM is a mechanism using which you can control various QTP operations from outside QTP. Using QTP Automation Object Model, you can write a code which would open a QTP test and associate a function library to that test.

Example: Using the below code, you can open QTP, then open any test case and associate a required function library to that test case. To do so, copy paste the below code in a notepad and save it with a .vbs extension.
1
2
3
4
5
6
7
8
9
10
11
12
13
'Open QTP
Set objQTP = CreateObject("QuickTest.Application")
objQTP.Launch
objQTP.Visible = True
'Open a test and ass
objQTP.Open "C:\Automation\SampleTest", False, False
Set objLib = objQTP.Test.Settings.Resources.Libraries
'If the library is


















If objLib.Find("C:\SampleFunctionLibrary.vbs") = -1 Then '
  objLib.Add "C:\SampleFunctionLibrary.vbs", 1 '
3) By using ExecuteFile method.

ExecuteFile statement executes all the VBScript statements in a specified file. After the file has been executed, all the functions, subroutines and other elements from the file (function library) are available to the action as global entities. Simply put, once the file is executed, its functions can be used by the action. You can use the below mentioned logic to use ExecuteFile method to associate function libraries to your script.

1
2
3
4
5

ExecuteFile "C:\YourFunctionLibrary.vbs"





4) using LoadFunctionLibrary method.

LoadFunctionLibrary, a new method introduced in QTP 11 allows you to load a function library when a step runs. You can load multiple function libraries from a single line by using a comma delimiter.

1
2
3
4
5
6
7
8
LoadFunctionLibrary "C:\YourFunctionLibrary_1.vbs"
LoadFunctionLibrary "C:\FuncLib_1.vbs", "C:\FuncLib_2.vbs"