Results for QTP Related

How To Work With Automation Object Model In UFT?

May 25, 2017
AOM stands for Automation Object Model. This is an way to use UFT/QTP  and its resources . By this approach we can control the QTP from a separate program like-a VBS,macro. This is accomplished using  COM interface.that gives a freedom to access the all most 90% of the components of the software. Based on COM , AOM can communicate with the components.(access different methods,properties,object). It provides a set of controls, methods to help a developer/automation tester to execute script without touching UFT. It is externally useful while triggering batchrun from Jenkins or making an one click automation.

What is proper use case

  • This is useful when we want to change the QTP /UFT options during run time
  • Want to control UFT/QTP from our other application
  • Want to do some repetitive task in a regular interval
  • Migrating to continuous integration
  • Want to schedule scripts in a machine.
AOM is the better solution for the above uses. It uses COM (Component Object Model)- In the below section, we will see how to create an object of UFT application and work with different components of it.
There are three popular ways to create object of quick test-
Visual Basic Way:
Dim qtApp as QuickTest.Application
set qtApp=New QuickTest.Application
VBScript way:
Dim qtApp
set qtApp=CreateObject("QuickTest.Application")
Java Script way
var qtApp=new ActiveXObject("QuickTest.Application")
You can choose any one.But in this blog I am going to take Vb scripting:
Basic Settings
Dim qtApp
set qtApp=CreateObject("QuickTest.Application")
qtApp.Launch  ' launch QTP/UFT
qtApp.Activateview "Expertview" 'Open Expert View can be "keyWordView"
qtApp.showPaneScreen "ActiveScreen",True 'show the Active Screen can also be set 
'as "Debugviewer",True or "DataTable" False
qtApp.WindowState="Maximized" 'Maximize the UFT,can aslo be set as "Minimized"
qtApp.Test.Settings.web.BrowserNavigationTimeOut=50000
qtApp.Test.Settings.web.ActiveScreenAccess.userName="myUserName"
qtApp.Test.Settings.web.ActiveScreenAccess.password="password"

Run Options
qtApp.options.run.ImageCaptureForTestResult="onError"
qtApp.options.run.RunMode="Fast" can be set to Normal or slow based on the network speed
qtApp.options.run.viewResult=False ' can be true if you want the qtp result to display 
'after a run
qtApp.Test.Settings.Run.ObjectSyncTimeOut=100000
qtApp.Test.Settings.Run.DisableSmartIdentification=false 'can be true
Run Settings
This can be achieved in two ways ...

  1. Either you follow the hierarchy
  2. Or create an object of the test module

set qtTest=qtApp.Test
qtTest.settings.run.IterationMode="AllIterations" ' can be rngIterations or rngAll
'to run from iteration x to iteration y
qtTest.settings.run.startIteration=1
qtTest.settings.run.EndIteration=3
qtTest.settings.run.onError="NextStep" 'can be stopped by passing "Stop"
' or we can show error dialog by passing "Dialog"
Result Settings
Dim qtResultOpt
set qtResultOpt=CreateObject("quickTest.Run ResultsOptions")
qtResultOpt.ResultLocation="C:\testpath\Result\"
qtTest.Run qtResultOpt

if you move all result to a file:
const forReading=1
const forWritting=2
dim fso,f,result
set fso=CreateObject("scripting.FileSystemObject")
set f=fso.openTextfile("c:\test\result.txt",forWritting,True)
'you can create the text file by using fso
set qtResultOpt=CreateObject("quickTest.Run ResultsOptions")
qtResultOpt.ResultLocation="C:\testpath\Result\"
qtTest.Run qtResultOpt
result=qtTest.LastRunresults.Status
f.write("test1:Name of the test")
f.write(result)
f.writeBlankLines(1)
'close f,set objects to null if you have no further use
Library Settings
dim qtlibs
qtlibs=qtApp.Test.Settings.Resolurces.libraries
'to remove all
qtLibs.removeAll
Add a library:
If qtLibs.find("path of the lib"\abc.vbs")=-1 then
qtlibs.Add "path of the lib"\abc.vbs",1
End If
qtApp.Test.Save ' in this case you have to open the test in edit mode,readonly false

Repository Settings
set qtRepositories=qtApp.Test.Action("Action Name").ObjectRepositories ' for which the 
'repository needs to be added
If qtRepositories.find("path of the lib"\abc.tsr")=-1 then
qtRepositories.Add "path of the lib"\abc.tsr",1
End If
Environment Variable Settings
qtApp.Test.Environment.value("userName")="myUserName"
qtApp.Test.Environment.value("password")="password"
Action Settings
qtApp.Test.Actions.Count 'return the actions present in the test
qtApp.Test.Actions("Name of the action like 'Action1'").Description
'returns the description
qtApp.Test.Actions("Name of the action like 'Action1'").Name
'returns the name
'run a particular action by index
qtApp.Test.Actions(index as 1/2).Run
or
setqtTest=qtApp.Test.Action(index)
RunAction "Action2",oneIteration 'can be multiple iterations by providing the iteration number
Recovery Settings
'removing all recovery
set qtTestRecovery=qtApp.Test.Settings.Recovery
If qtTestRecovery.count>0 then
qtTestRecovery.RemoveAll
End If
'add recovery
qtTestRecovery.Add "path of the recovery file","Name of the recovery",1,"description"

'enabling the recovery:
For intIndex=1 to qtTestRecovery.count
qtTestRecovery.item(intIndex).Enabled=True
Next
or
qtTestRecovery.Enabled=true
'specify when to activate
qtTestRecovery.setActivationMode="onError"
Datatable Settings
qtApp.Test.Settings.Resources.DataTablePath="Path of your data table"
Log tracking Settings
with qtApp.Test.Settings.LogTracking
.Includeinresult=False
.port=18081
.IP="127.0.0.1"
.MinTriggerLevel="Error"
.EnableAutoConfig=False
.RecoverConfigAfterRun=False
.configFile=""
.MinConfigLevel="Warn"
End With
There are two launcher available out of the box.

  1. Web Application
  2. Window Application

Web launcher Settings
qtApp.Test.Settings.Launcher("Web").Activate=true 'can be false
qtApp.Test.Settings.Browser="IE", Can be chrome,firefox if supports
qtApp.Test.Settings.Address="www.google.com"
qtApp.Test.Settings.CloseOnExit=true

Windows Application launcher Settings
qtApp.Test.Settings.Launcher("Window Application").Activate=true 'can be false
qtApp.Test.Settings.Applications.RemoveAll 'removes all pre loaded Applications
qtApp.Test.Settings.RecordOnQTDescendant="False" 'record settings
qtApp.Test.Settings.RecordOnSpecifiedApplications=True


Addins Settings
arrAddins=qtApp.GetAssociatedAddinsForTest("Test path and Test Name")
'check if loading is successful
blnAddinRequired=False
For Each testAddin in arrAddins
If (qtApp.Addins(testAddin)).status <> "Active" then
blnAddinRequired=True
Exit for
End if
Next
'if change in the loaded addins is necessary
If blnAddinRequired Then
Dim blnActivateOk
blnActivateOk=qtApp.SetActiveAddins(arrAddins,error description)
If Not blnActivateOk Then
WScript.quit
End if
End if 
Set Parameters
To work with these, we need to create these parameters in QTP first.
Set pDefcoll=qtApp.Test.ParameterDefination
Set qtpParam=pDefcoll.GetParameters()
on Error Resume Next
qtpParam.Item("UserName").value="myUserName"
qtpParam.Item("Password").value="myPassword"
How to save Test
If qtApp.Test.IsNew Then
qtApp.Test.SaveAs "path of the script and Script Name"
Else
qtApp.Test.Save
End If
How to Connect To ALM/QC
qtApp.TDConnections.Connect "QCURL","Domain","Project Name","UserName","Password",false
How to Run a Test from ALM/QC
qtApp.TDConnections.Connect "QCURL","Domain","Project Name","UserName","Password",false
If qtApp.TDConnection.IsConnected Then
qtApp.Open [QualityCentre]Subject\path\script Name,False
qtApp.Test.Run
qtApp.TDConnections.Disconnect
How to Log a bug in ALM/QC
Here is complete guide of the code: http://www.ufthelp.com/2014/09/how-to-log-bug-in-alm-using-ota.html Here is a small different way to do:
Dim qcApp
 Dim BugFact,NewBug
 
 Set qcApp = CreateObject("TDApiOle80.TDConnection")
 'Intilizing the QC connection
 qcApp.InitConnectionEx "https://alm.com/qcbin"
 'Verifying User is connected
 If qcApp.Connected Then
  Print "User Connected to ALM Server"
 Else
  Print "User is not Connected to ALM Server"
  Exit Function 
 End If
 'Filling the UserName and Password for ALM
 qcApp.Login sUName,sPwd
 'Verifying User is Logged into ALM
 If qcApp.LoggedIn Then
  Print "User is Logged into ALM Server"
 Else
  Print "User is not Logged into ALM Server"
  Exit Function 
 End If
 'Connects user to specified Domain and Project
 qcApp.Connect sDomain,sProject
Set BugFactory=qcApp.BugFactory
Set Bug=BugFactory.AddItem(Nothing)
Bug.Status="New"
Bug.Summary="Test Bug"
Bug.Priority="3-Medium"
Bug.AssignedTo="Dev Team"
Bug.DetectedBy=myUserName
Bug.Post
Easy Way to Build this AOM file: Setup everything in UFT/QTP: Option 1: Go to test settings->General Tab-->Object Identification Tab-->Click on Generate button-->Provide the path-->Provide the name-->Click on save Option 2: Go to Test-->Settings-->Properties Tab-->Click on Generate button-->Provide the path-->Provide the name-->Click on save Option-3:Go to tools->Option-->General Tab-->Click on Generate button-->Provide the path-->Provide the name-->Click on save after few settings you will be able to understand the settings.
How To Work With Automation Object Model In UFT? How To Work With Automation Object Model In UFT? Reviewed by Animesh on May 25, 2017 Rating: 5

How To Use Accessibility Check Point In QTP

September 17, 2010

Like another checkpoints,QTP provides one more check point to check websites.
web industry is becoming boom now. Designers create a lot of webpages with their customized codes,logos,pictures etc. But they must follow the w3 school's guidelines for developing web.
Mostly it is based on customer's requirements and guideline that abide by the W3 school's guidelines.
Accessibility check point:
It verifies whether the webpage in our web application is developed according to W3C (World Wide Web consortium) Rules and Regulations.

This can be configured as below written:
  • Active X control check
  • alt property for images check
  • Applet check
  • Frame title check
  • Multimedia link check
  • Server side image check
  • Table check

Configuring accessibility checkpoint: 
Tools menu--> options-->web--> advanced--> check/uncheck items--> click apply--> click ok
How to insert:
under recording mode with web environment >insert>checkpoint>accessibility checkpoint>show the webpage>click ok>click ok>stop recording.

You can check out this link to know how the checkpoint info is saved in QTP
How To Use Accessibility Check Point In QTP How To Use Accessibility Check Point In QTP Reviewed by Animesh Chatterjee on September 17, 2010 Rating: 5

How to Use Database Checkpoint In QTP

September 17, 2010
When we talk about the client server architecture, we talk about  front end and back end. So whenever we give any value from front end it stores data in back end database. Database checkpoint checks the contents of database accessed by application(front end). Database check points creates a check on record set.
QTP captures the the current record set and treats as it as Expected data.
However Database can be inserted into test or components and it can be modified as per our need.here we do not need to put tool under Recording mode and we do not need AUT since data is from backend.
There are two ways by which we can configure database checkpoint:

  • Microsoft Query builder
  • Manual query creation

   
Navigation:
Insert  Menu > checkpoint > Database checkpoint >choose "specify SQL statement manually" option >click next > click create > select machine data source > Select DSN (QT_flight32) > click ok > enter SQL statement (select * from orders) > finish > click ok.


You can check out this link to know how the checkpoint info is saved in QTP
How to Use Database Checkpoint In QTP How to Use Database Checkpoint In QTP Reviewed by Animesh Chatterjee on September 17, 2010 Rating: 5

How To Use Bitmap checkpoint In QTP

September 17, 2010

Bitmap checkpoint:

It compares bitmaps; we can compare complete bitmaps as well as part of the bitmaps.Mostly we use to check if selected area of a webpage is bitmap image or not.
Navigation:
Keep tool under Recording mode > Insert menu > Checkpoint > Bitmap checkpoint > show the Bitmap >click ok >select "check only selected area" option if we want to compare part of the bitmap > click ok >stop recording.

While testing map,Zooming functionality We use Bitmap frequently.

You can check out this link to know how the checkpoint info is saved in QTP
How To Use Bitmap checkpoint In QTP How To Use Bitmap checkpoint In QTP Reviewed by Animesh Chatterjee on September 17, 2010 Rating: 5

How To Use Text Area Checkpoint In QTP

September 17, 2010

Text Area Checkpoint:
It checks the text area present in the application.
Navigation:
Keep tool under Recording mode > Insert menu> Checkpoint > Text area checkpoint > Mark the area of text > select one or more options
(Match case, ignore spaces, exact match, text not displayed.)
Click ok and stop recording.
Mostly while after doing some operation if we are expecting some text to be appeared in the application, We use this type of check point.

Like--after successful login Welcome UserName should present in the application.
or after successful upload of a file Uploaded successfully text should be present in the application.
 
Sometimes we say that TextArea check point is nothing but text check point.
  


 
How To Use Text Area Checkpoint In QTP How To Use Text Area Checkpoint In QTP Reviewed by Animesh Chatterjee on September 17, 2010 Rating: 5

How To Use Text Checkpoint in QTP

September 17, 2010

Text Checkpoint:
It Checks object's text property value in different ways.

Navigation:
Keep tool under Recording mode >Insert menu > checkpoint > Text checkpoint > Show the object > click ok > Select options
(Match case; ignore spaces, exact match, text not displayed.)
We can select one or more options > click ok & stop Recording.
We can insert a text checkpoint while recording a script in qtp.
example suppose i want to insert a text checkpoint for agent name in sample Flight application.follow the steps
1)click on record button
2)invoke the Flight application
3)Insert the agent name
5)In qtp click insert menu
6)select the text checkpoint option
7)place the cursor over the Agent name text field.
8)select the text checkpoint properties
9)click on ok
10)continue to record the remaining script
11)stop the recording and replay the script
12)see the report


 
How To Use Text Checkpoint in QTP How To Use Text Checkpoint in QTP Reviewed by Animesh Chatterjee on September 17, 2010 Rating: 5

Standard Checkpoint in QTP

September 16, 2010

Standard Checkpoint:
It checks object property values. We can use this checkpoint for checking any property value.
Navigation for Inserting standard checkpoint
Keep tool under recording mode > place cursor in desired location > Insert > check point > Standard checkpoint > Show the object > click okay > select property and enter expected results & click Ok and stop Recording.
Navigation for Editing standard checkpoint
Select Checkpoint statement and right click > choose checkpoint properties option > modify the value > click Ok.
Navigation for Deleting standard checkpoint:
Select Checkpoint statements and right click > choose delete option.
Inserting Standard check points through active screen:
View > Active Screen >place cursor in desired location >Place mouse pointer on active screen & right click> choose insert standard checkpoint option > click ok > enter expected result > click ok
Note: Inserting Standard check points through keyword view same as in expert view.
Note: We can insert standard checkpoints in 3 ways.
  1. Through expert view,
  2. Through keyword view,
  3. Through Active screen.
Mainly below can be tested through QTP Standard Checkpoints…
  1. Image
  2. Web Table
  3. General window table
  4. Web page general properties
  5. Any custom property for web
Standard Checkpoint in QTP Standard Checkpoint in QTP Reviewed by Animesh Chatterjee on September 16, 2010 Rating: 5

Synchronization in QTP

September 12, 2010

Waiting time in the sense that if you have an application in which you have 3 steps for example. Let's say you are recording the steps where the first step is to enter the information, second step is clicking submit button and third step is get the order No.This is like our flight reservation system.Now when you click submit button it may take few seconds to several minutes depending on the application or internet speed. After that we can get the order no.But when you play this in Qtp it does it very fast, it does not wait for processing of information after you click submit button and may try get the order no before it is getting generated which will give error. So, to overcome such problems we insert synchronization point. By inserting synchronization point we are asking QTP to wait till the order no is getting generated and then retrieve the order no.
It is a process of matching the speeds of both QTP and AUT in order to get proper execution and results.
Where Synchronization is required:
During test execution QTP gives instructions one by one with same speed, but AUT takes less time for some operations execution and more time for some operations execution, that time we may not get proper execution and results. In order to get proper results in between QTP & AUT synchronization is required.There are several methods available in QTP for synchronization.
  1. Inserting Wait statements.
  2. Inserting Synchronization points.
  3. Increasing Tool default synchronization time.
  4. Sync Method (Only for WEB)
  5. Exist Property
Inserting Wait Statements:
We can insert wait statements in our test in order to make QTP to wait until AUT completes current operation.
Syntax:
Wait(time in seconds)
Note: If we insert wait statements QTP waits up to maximum time even though operation is completed.
Inserting Synchronization point:
Place cursor in desired location>keep tool under recording mode > Insert menu > Synchronization point > show the object > click ok > select property name & Value (True)>enter time in Mille seconds>click ok>Stop recording.
Note: if we insert Synchronization points, it does not wait up to maximum time, after completion of the current operations, it goes to next step immediately.
Syntax:
object hierarchy.waitproperty "property name",value,time in milli seconds.
Increasing Tool default synchronization time:
Navigation: File>settings>run tab>increase object synchronization time out>apply>ok
Note: If we increase QTP tool default time that can be applied for all statements in the test, but QTP does not wait up to maximum time unnecessarily, After completion of one statement execution it goes to next statement immediately.
Sync Method: (only for WEB)
Waits for the browser to complete current navigation.
Syntax: Object Hirearchy.Sync
Ex: Browser("Yahoo! Toolbar").Page("Yahoo! Toolbar").Sync
Selecting an appropriate Method:
  1. Suppose in our test one or more statements only are taking more time for execution then selecting "Inserting synchronization method" is better.
  2. Suppose in our test more statements are taking more time for execution then selecting "increasing tool time out" .
  3. Above two are local features but wait statement is Vbscript feature, even though some drawbacks are there in using wait statement, it is better to use wait statement in functions.
These are general Synchronization methods applicable to general systems. Please visit
http://relevantcodes.com/qtp-synchronization-for-ajax-applications/

for synchronization in Ajax application.

Synchronization in QTP Synchronization in QTP Reviewed by Animesh Chatterjee on September 12, 2010 Rating: 5

Commonly Used Function/Methods in QTP

September 11, 2010
In this post I am trying to figure out few commonly used methods/functions or commands used in QTP.
These methods generally used for making QTP work smoothly.

The following methods empowers us to organize our tests,strengthen the tests and perform desired actions based on our requirements.

While designing a framework maintaining the script or to make it stabilized, these methods are really important. Mostly these methods are inexpensive in terms of cost of usage.Rather they are non comparable with the expensive steps perform.





Activate
It activates dialog boxes/Windows or pages.This is one of the precondition step before we do any set of operation on UAT. This operation will set the the window or page on front so that QTP can perform next set of operation viz actual step

Example:
 
Dialog("Login").Activate
Window("Flight Reservation").Activate

Syntax is: ParentObject.Activate
Exist

This method checks the availability of an object on the application. Prior to any step if we perform this precondition check ,we can avoid lots of delay or failure.Based on this we can set custom message to notify the test engineer that the corresponding object exist or not. Example:
 
dim Check_condition [as boolean]
Check_condition=Dialog("Login").exist
if(Check_condition) then
do something
else
msgbox "Object does not exist"
End if
Syntax is: variableName=Object.Exist
This command will return true if the condition satisfied else return false. We can use a timeout syntax here. I mean if we know that the object will appear after some 10 seconds after the last step performed,we can put a time out value: Example:
 Window("Flight Reservation").Exist(5)
Select
It selects an item from combo box or list box
Syntax is: variableName=Object.Select "item"
 Window("Flight Reservation").WinComboBox("Fly From:").Select "London"
Window("Flight Reservation").WinComboBox("Fly To:").Select "Kolkata"
Minimize,Restore,Move
Minimize: It will minimize the test window. Restore: This command will restore or maximize the test window. Move:This will move the test window to a position in the screen . It will move the test window with respect to screen
Window("Flight Reservation").minimize
Window("Flight Reservation").Restore
Window("Flight Reservation").Move(x,y)
//here x,y are the coordinates.
GetVisibleText
It returns Text from the specified area. This is feature of QTP,I would prefer GETROProperty("Value" or "text") Syntax: Variable =object hierarchy.getvisibletext
dim x
//[as String]
x=Window("Flight Reservation").WinComboBox("Fly From:").GetVisibleText
msgbox x
SET
This is a very tricky method or command of QTP. May be multitasking command. We can use it in three ways..

  1. Setting value to textbox or editbox
  2. Radio button selection
  3. Select or deselect checkboxes
//Example of textbox
Dialog ("Login").WinEdit("Agent Name").Set "AskQTP"
//Example of setting radio button
Window("Flight Reservation").WinRadioButton("Business").Set
//Example of checking checkboxes
Window ("Flight Reservation"). Dialog("Open Order").WinCheckBox("Order No.").Set "ON"


Custom Function-CloseQTP
This method is a custom function to close QTP process in a system.
Function CloseQTP()
   Set objService = GetObject("winmgmts:\\.\root\CIMV2")
   Set objProcessAllQTP = objService .ExecQuery ("Select * from Win32_Process Where Name = 'QTPro.exe'")
   For Each objProcess in objProcessAllQTP 
   objProcess.Terminate()
   Next
   Set objService = Nothing
   Set objProcessAllQTP = Nothing
End Function
Custom Function-CloseBrowser
This is also one custom method to close open Browser.
Function CloseAllBrowsers(BrowserName)
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
if(BrowserName=InternetExplorer) then
Set oExec = WshShell.Exec("taskkill /f /im iexplore.exe")
else if(BrowserName=FireFox) then
Set oExec = WshShell.Exec("taskkill /f /im firefox.exe")
else if(BrowserName=Chrome) then
Set oExec = WshShell.Exec("taskkill /f /im chrome.exe")
wait 10
End Function
or else we can also follow the below process:
Function CloseQTP(BrowserName)
if(BrowserName=InternetExplorer) then
BrowserProcess=iexplore.exe"
else if(BrowserName=FireFox) then
BrowserProcess=firefox.exe"
else if(BrowserName=Chrome) then
BrowserProcess=chrome.exe"
end if
Set objService = GetObject("winmgmts:\\.\root\CIMV2")
Set objProcessAllBrowser = objService .ExecQuery ("Select * from Win32_Process Where Name = 'BrowserProcess'")
For Each objProcess in objProcessAllBrowser 
objProcess.Terminate()
Next
Set objService = Nothing
Set objProcessAllQTP = Nothing
End Function
Commonly Used Function/Methods in QTP Commonly Used Function/Methods in QTP Reviewed by Animesh Chatterjee on September 11, 2010 Rating: 5

All about Object Repository And Operation In QTP

September 07, 2010
image credit:www.ise.ncsu.edu
Object Repository:
It is a storage place of QTP where we can store the objects information those are required for testing and it also acts as interface between the test script and the AUT in order to identify the objects during execution.

In a simple term an object is a graphic user element in an application and object repository is a graphical representation of the objects.
Object:
Object is something, which has structure and properties.Mostly this concept is based on OOPs hierarchy of Objects.. It consists of data that describes the object [properties] and Functions that can be performed on that object[methods]
In OOPs an object is an instance of a class and in QTP, the objects are defined by class.
Like a go button in web context is an instance of webbutton.

It is collection of objects stored in XML file . Objects will have its own properties by which QTP will identify the objects uniquely. During recording this entry to this file is automatically done by QTP.

The entry will have a logical name about the object and physical description about the object in the right side pane.
We can perform several operations:
1. Rename the logical name.
2. Moving objects from one hierarchy to others
3. Change the object description
4. Delete object
5.Highlight selected object 
6. Locating an object
7. Update physical description
8. Filtering object etc.

          
Software objects:
We call windows, WebPages, buttons, edit boxes, check boxes etc.. as software objects.
Types of Object in QTP:
There are four types of object available in QTP.
1. Run time objects
2. Test objects
3. Utility objects
4. Automation objects/User defined objects.
Run time objects: The objects present in the AUT. Ex: Buttons, links, etc…
Test Objects: References of Run time objects. Ex: WinEdit, WinButton, WebButton, Link, etc…
Note:
Test objects names vary from one environment to another.
Ex:
Run time objects Test objects in windows EnvironmentTest objects in VB
Environment
Test objects in web Environment
buttons WinButton VBButton WebButton 
Edit box WinEdit VBEdit WebEdit 
Check box Wincheckbox Vbcheckbox Webcheckbox 


Utility objects

They are QTP reserved objects used for testing and result reporting.
Ex:
1. SystemUtil for launching/closing the application.
2. Reporter for defining results.
3. Services for inserting transaction points
4. Environment for using environment variables
Automation objects/User defined objects
User can create objects; those can be used for performing specific operations. Ex: Creating objects in file system object class, adodb.connection class, dictionary object class, excel. Application class etc.
There are two types of repository available in QTP.
  1. Local repository (.MTR extension-Module Test Repository )
  2. Shared repository(.TSR extension- Test Shared Repository)
Local Repository:

  • QTP creates a Local Repository for every action automatically during Recording. That cannot be shared among tests. 
  • User can add some more objects to Local repository
  • User can perform rename, delete operations in local repository. As it is QTP internal file user no need to save modifications.
How to navigate:
Resource menu-->object repository-->Objects-->Add objects to Local-->show the object-->Click ok
By default QTP saves its objects.

How to rename the object in local object repository:
We can rename the object in object repository. Navigation >>resources-->Object repository-->select the object which you want to rename-->right click on that object-->rename-->type the correct name-->select some other object--> It will automatically rename the previous object

How to delete objects from Object repository:
We can delete the object in object repository. Navigation >>resources-->Object repository-->select the object which you want to delete -->right click on that object-->select delete--click on confirm delete-->close repository.

How to add Objects repositories to an action:
if we miss to add object during recording time but we need that 

 
Shared Repository:

User (Test Engineer) creates shared repository by adding objects. That can be shared among number of tests. Using this method user can perform modifications on objects easily Navigation: Resource menu-->object repository manager (Short cut key Ctrl+R)-->Object-->Add Objects-->show the window/objects-->Click ok

  •          Selected object only--It stores only one object
  •          Default object types--It stores all default objects
  •          All objects types--All default objects with static objects
  •          Selected object types--It stores objects along with Object class. in this case we can add more class.


How to rename the object in shared object repository:

go to resource-->Object repository manager-->file-->open-->click on the browse button to browse path of the repository file-->select file-->enable editing-->select object-->right click -->choose rename-->change the name-->click on the other object-->the last object name automatically changed-->save the file-->close repository manager

How to delete the object in shared object repository:
go to resource-->Object repository manager-->file-->open-->click on the browse button to browse path of the repository file-->select file-->enable editing-->select object-->right click -->choose delete -->confirm deletion-->save the file-->close repository manager
All about Object Repository And Operation In QTP All about Object Repository And Operation In QTP Reviewed by Animesh Chatterjee on September 07, 2010 Rating: 5

What is Keyword Driven Framework??

September 07, 2010
With the advancement of automation framework, after record and playback ,Keyword driven framework is the most robust and acceptable framework while automating huge testcases.

It is true that sometimes,if we change the approach , we may get more bugs via automation.Breadth over depth approach to testcase automation gives more bugs. Instead covering all features ,it is better to go for a specific features covering all the objects. There should be a balanced approach for selecting depth and breadth testing.

The more the framework easy to use ,more and more test engineers will jump into automation that will intern increase the coverage and testcase count.Automation will never face the starvation issue as there will be plenty of test cases to automate.

This framework is an application independent way to design testcases. The testcases are supported via data table. Mostly a database supports the vocabulary of keywords.A core library is required to read all these lines from Excel or data source and convert them into equvalent QTP /Selenium/other tool command.

The keywords are simple and clear [like open_bowser,Close_browser,setValue].Each keyword will be mapped to a known action.There can be multiple inputs for the action. Like -Locator,Text. Even an action can be an input to another action.Now this framework is combination of tables[Cycle table,test table]. Below are the sections where I have shown how is the structure of a keyword driven framework...

In keyword driven testing there exists five different parts..

  1. Control file
  2. Testcase file
  3. Startup Script
  4. Driver Script
  5. Utility Script
What is Control File?
Well, this file contains all testcases. Based on some parameters or conditions some of the testcases will be executed.
What is Testcase File?
Detailed design  test cases.Mainly written column like-Keyword ,Object Name , Parameters.It is an excel file in most of the cases.This will also include the start up and tear down methods.
What is Startup Script?
This is the initialization script. It creates the environment to run the testcases.Assembles the testcases those are marked to be runable in control file.
What is Driver Script?
It drives the test flow,gets input from stratup script [Which scripts to run]. It reads the testcase file for the corresponding steps. It takes the input passes that to script engine to generate the code according to the test tool and corresponding script gets executed.
A good framework should allow any combination of features to be tested. Initial days we used Excel to select testcases.As technology progressed,we use web interfaces with simple UI where check box can be checked to select testcases.User friendly,self explanatory web interface ensures good productivity as it reduces the technical barriers.Jenkins,QC are very good example.  This feature will support mini regression to full regression.
What is Script Engine or Utility Script?
Script engine is responsible for tool specific code generator. Kind of tool understandable code generator. The code will be executed on the tool.
Utility script: Utility Scripts are the low level test steps to perform some operation.Some common utility methods are-

  • LaunchApplication
  • CallScript
  • ReportLog- It is also known for debug logger. It gives more clarity on real bug and noice.

Sometimes all supported libraries we put in Utility Script.like-

  • File Handling,
  • String handling
  • Database access
Execute -Execute and Execute should be main aim for this approach. This is keep the maintenance low and scripts updated. This will give great ROI.
There may or may not be any object repository present. There is further reusable concept hence all functions, keywords etc will be generic in nature.
Advantages:
  • Change management is easier
  • Does not dependent on the UAT
  • Much easier to extend.
  • Similar to functional test script so easy for non technical or non tool experts in terms of understanding.It is easy for them to develop scripts.
  • When developed block by block it becomes highly user friendly.Real power of functional decomposition can be seen. 
  • This will also cut down the test engineers tedious and lengthy testcase creation time. Manual testers will have  bugs.
  • Easy to modify so maintenance cost is low with compared to other framework.So greater ROI could be achieved.
  • Advanced keyword driven framework is having two layers…one is pure code layer and other is pure English or non code elite language.Functional people can prepare the test cases very easily.
  • If the infrastructure is separated from logical layer then any test cases can be automated.
  • After a couple of months when the basic building blocks(unique components) are ready to design  a functional flow, the development cost will down.
  • So this will provide better ROI.
  • If application is getting changed, it can determine the changes on run time .It can change only that component.No need to debug the entire script. Hence it is very easy to maintain.

Due to simple English interface, it is best for manual test engineers,functional analysts and business analysts.
Disadvantages:

  • Naming convention is tough for large projects.
  • Very tough to remember the keywords.
  • Initial investment for framework design is high.
  • High skilled labor is must for initial days of the project.
  • Not very to understand for new comers.
So to conclude, it is one of the finest flavor of data driven testing but having most time consuming process.But the keyword preparation is one time effort. Once completed,it can handle any size of project.This approach will uncover the code issues in an automation at earliest. Automation code is also a software code that needs to be tested.By this approach,we can test automation code as well.As a result it is more likely to uncover more bugs.
image credit :cdn2.codenutz.com
What is Keyword Driven Framework?? What is Keyword Driven Framework?? Reviewed by Animesh on September 07, 2010 Rating: 5

How to work with Data Table in QTP

September 05, 2010
Well in the last post we have learnt about the function concept of QTP. Today i will cover few more about datatable.

1. Mostly we will be using MS-Excel for QTP. There are two methods to invoke one excel file to your test.
1.1. Save your test to a specific folder.
1.1.1. Open that folder via window explorer.
1.1.2. Find Default.xls
1.1.3 Rename it as Default-old.xls
1.1.4 Now rename your datasheet as "Default.xls"
1.1.5 Paste it here.
1.1.6. Reopen your script viz test.

you can find the excel is populated in the datatable area with exact sheetnames given in that excel.

2. Otherwise you can dynamically add excel file through code.
I would say this is very good method. Every time you invoke a excelfile that will load into your primary memory . So it is going to consume the primary memoory. It is better to load files whenever required.

The few lines are enough to start with

datatable.AddSheet("Sam")
datatable.ImportSheet "H:\Automation\sam.xls",1,"Sam"
msgbox datatable.GetSheet("Sam").GetRowCount 

The first line will add a sheet.(i prefer not to touch the Global or the sheet1)
The secondline will import the sheet to the QTP datatable in the sheet called Sam.1 signifies it will import the first sheet to sam.

Now you need to know how many rows are there in the datatable.

Now we need to read the rows one by one...for this we need to select a particular row first.
the sysntax is
datatable.SetCurrentRow(i)
i is the looping variable

datatable.AddSheet("Sam")
datatable.ImportSheet "H:\Automation\Sam.xls",1,"Sam"
s= datatable.GetSheet("Sam").GetRowCount

For i=1 to s
   datatable.SetCurrentRow(i)

Next

All right now we need to catch the values specified in the sheet.

The syntax is ...
datatable(" Colomn Name"

like-
datatable.AddSheet("Sam")
datatable.ImportSheet "H:\Automation\Sam.xls",1,"Sam"
s= datatable.GetSheet("Sam").GetRowCount

For i=1 to 5
    datatable.SetCurrentRow(i)
msgbox datatable("Name")
Next

so it will give me all the names specified in the sheet under "Name" colomn


Remember one thing always...
Datatable starts with 1 if you are using excel.
But Array starts with 0
How to work with Data Table in QTP How to work with Data Table in QTP Reviewed by Animesh Chatterjee on September 05, 2010 Rating: 5

QTP Assignment work on Funtion

September 02, 2010
Today I was planing to write something on QTP Assignments....
To start with..

Write a small function that with print some text.

The structure of a function is

Function Function_name
..........
lines of code
End Function


So the function would be
Function printline
msgbox "animesh"
End Function

If you have written this on your own...good..

Now write one function that will take value from user and send it to this function for printing.

So now it will be a calling and called function concept. The first function will take value from user and call the second function with a paarameter by which it will pass the value to the second function viz the called function.


Call catchvalue
Calling Function:
----------------------
Function catchvalue
input=inputbox("Enter some value")
f=printline(input)
End Function
Called Function:
-------------------------------
Function printline(c)
msgbox c
End Function

c is the argument of the function printline.

3.Now let us do it 5 times...

simple..
it will a for loop...like
for i=1 to 5
Call catchvalue

next

Calling Function:
----------------------
Function catchvalue
input=inputbox("Enter some value")
f=printline(input)
End Function
Called Function:
-------------------------------
Function printline(c)
msgbox c
End Function

4.Now let us do it n times...n will specified by user
 
input1=inputbox("Enter some iteration value")


 for i=1 to input1
Call catchvalue
next
Calling Function:
----------------------
Function catchvalue
input=inputbox("Enter some value")
f=printline(input)
End Function
Called Function:
-------------------------------
Function printline(c)
msgbox c
End Function

5. now let us make it such a way that it will work for all positive no but if other input is given then it will ask again for input.
QTP Assignment work on Funtion QTP Assignment work on Funtion Reviewed by Animesh Chatterjee on September 02, 2010 Rating: 5

Object Identification in QTP while Recording

August 30, 2010
Object identification by QTP is a topic to learn by all of us. I read lot of documents and tried googling on this.I found out some of the satisfactory solution and easy to learn process of Object identification.

Object identification by QTP is a bit complex mechanism.It runs an algorithm to detect an object under a dynamic page similar way that a person would look at a photograph and try to remember details.

The algorithm:
1. QTP looks at the object and try detect the class of the test object.For each test object class,QTP has a list of mandatory properties so when we record an object QTP learns these dafault property values. It tries to determine the object uniquely.

Think about a scenario where QTP is trying to enter value to a ID field and a PASSWORD filed in a login page.even though there are two textfileds available in the web page, their names are different, so QTP can identify these two fileds uniquely by mandate property-name.

2. If mandatory properties fails to determine the object uniquely ,QTP tries to identify an assistive property. It adds these properties one by one.It continues the same operation untilit has complited an unique description.

 Imagine there are two arrows present in a page called next.I mean the name is same for both the objects. Position of the arrows are..
1. Top of the page
2. Bottom of the page
Their names are same so, by, mandate property "name" , QTP can not identify this object . Now it will go for assistive properties.

Index value can be an assistive property for the same.
It is like a classroom having 30+ students . There is no roll no assigned to them. Now if we try to call one of them. Name is sufficient to identify uniquely. Problem will occure if there are 2/3 students having same name.
To solve this we might assign some value to each of these person to identify uniquely. Remember our own school days....Lambu Suman(Tall Suman), Archi-man(archimedes+Suman ,,Suman good at math),Changra Suman( Suman who is bit childish) are few names to identify each of the suman uniquely. This is kind of Assistive properties..

The code for this will look like:
Browser("xyz").page("abc").webbutton("name:=next","index:=0").click
Browser("xyz").page("abc").webbutton("name:=next","index:=1").click


3. If no assistive properties available or if assistive properties fails to determine the object properly then QTP adds a special ordinal identifier such as location ,source code etc.

EXP-Mandate-Webbutton-class object-button name= next
Assistive-Index
Ordinal-Coordinate.

Coordinate is the dafult ordinal identifier.
Object Identification in QTP while Recording Object Identification in QTP while Recording Reviewed by Animesh Chatterjee on August 30, 2010 Rating: 5

Browsers supported by QTP

August 30, 2010
QTP
Astra QuickTest 5.5 and QuickTest Professional 5.5
Internet Explorer: 4.01 - Internet Explorer 6.0 (with patch)
Netscape: 4.07 - 4.77, 6.0, 6.01
AOL: 5.0 and 6.0

Astra QuickTest 5.6 and QuickTest Professional 5.6
Internet Explorer: 5.0 - 6.0
Netscape Navigator 4.06 and later
Netscape 6.1
AOL: 5.0 and 6.0

Astra QuickTest 6.0 and QuickTest Professional 6.0
Internet Explorer: 5.0 - 6.0
Netscape Navigator 4.06 - 4.7x

Netscape 6.1, Netscape 6.22, and Netscape 6.23
AOL 5.0 and 6.0

QuickTest Professional 6.5
Internet Explorer: 5.01 - 6.0
Netscape Navigator 4.06 - 4.7x
Netscape 6.1, Netscape 6.22, and Netscape 6.23
AOL 5.0 and 6.0

Note:

Netscape 7.02 is supported by QuickTest Professional 6.5 with a patch. For more information, please refer to Problem ID 27673 - Does QuickTest Professional support Netscape 7.02.

If you are using a different version of Astra QuickTest or QuickTest Professional, you can find information on the supported browsers in the Astra QuickTest Readme file in the Supported Environments section.

QuickTest Professional 8.x
Microsoft Internet Explorer 5.5 Service Pack 2 - 6.0
Netscape 6.1, Netscape 6.22, Netscape 6.23, Netscape 7.02, and Netscape 7.1 AOL 8.0 and 9.0

Taken from:
http://www.discussweb.com/testing-tools/3377-what-all-browsers-supported-qtp.html
Browsers supported by QTP Browsers supported by QTP Reviewed by Animesh Chatterjee on August 30, 2010 Rating: 5

How to work with QTP

August 28, 2010
How to work with QTP is a systematic process. Lets us go through one by one....

a) Analyzing the application.............In this phase we check what kind of application on which tests needs to be performed. If required we need to add the addins or we need to buy the add ins.

b) Selecting Areas/Test Cases for Automation ....After successful pass of step-a we will identify the manual testcases or the scenarios that we can automate. We can not automate 100% of the application in general.
c) Planning (Effort estimation, Schedule, Work allocation and Automation Framework implementation)........  After step-b we will do a effort estimation for Step-b. We will also consider the schedule,framework efforet in this phase.QTP records raw lines of codes.So transferring those from code to framework or add to existing framework is an effort.In the last phase we will identify the team members and allocate them the work.
d) Creating Generic and project specific functions....While recording we might get some generic function like button press..it is common to all the window/pages...this can a be a good trics to write a small function on button press and can reuse them.Or we might get a new flow which is very specific to a business.

e) Creating required Automation resources (Functions, Object repository Files, Environment variable files---etc).........  This is as per organization test strategy.If test strategy says we need to do record playback then it is ok to record and store objects in object repository or else we will go descriptive programming.

f) Creating Tests (Using Object Repository or Descriptive Programming)...This is what i covered in step-e
g) Enhancing Tests...(Inserting Checkpoints, Output Values, Transaction points, Flow Control Statements, Synchronization, Parameterization---etc )
In this phase we need to create some validation points.

h) Debugging and running tests(Individual test execution, Test Batch execution --etc)
After enhancing the test , now , we need to check, if , it is working fine. or else we need to debug the script. Now we need to run the test.

i) Defining and exporting test results:
Now after the runing of the test we need to collect the test results.
j) Analyzing results:  In this phase we analyze the test results. the passes and fails.
k) Test reporting:  In this phase we report as per SLA criteria.
l) Defect Reporting using companies defect management system.:  In this phase ,we log defects in defect management system like-excel,bugzilla,QC etc.
m) Modifying tests:   After the defect fix or a case of new build we generally modify our tests.Why it is required??? just to save ourselves from pesticide paradox.
n) Performing re and regression testing ---etc   In This phase we generally run performance and regression testing again.
How to work with QTP How to work with QTP Reviewed by Animesh Chatterjee on August 28, 2010 Rating: 5

QTP Add ins

August 22, 2010
What QTP supports....

QTP supports almost all industry leading technologies, but by default it does not support, with respect to add in license it supports.

Default Add- ins of QTP are:

• Activex
• Visual basic
• Web.


Other available Add Ins are: .NET, Java, People soft, Siebel, TE (Terminal Emulators), SAP for GUI, Sap for Web, Oracle Apps, Web Services etc.

During QTP launching it shows Add in manger dialog box, Add in Manger lists out all available Add Ins in the company.

User needs to select appropriate Add Ins for his application or AUT.

One can select more than one Add Ins also; if we select unnecessary Add Ins QTP performance will be reduced.























Add in Manager will look like this snap....We need to select the correct add ins before we start.
Say my application in on java...I will check the java add in and will say ok.
QTP Add ins QTP Add ins Reviewed by Animesh Chatterjee on August 22, 2010 Rating: 5

Versions of QTP

August 22, 2010
Versions of QTP are written below............

• Astra Quick test (Mother tool of QTP) 1.0 to 5.0
• Quick Test Professional
• 5.6 – Nov 2002
• 6.5 – 2003
• 8.0 – 2004
• 8.2, 8.3 –2005
• 9.0,9.1-2006
• 9.2- 2007 mercury interactive
• 9.5 –2008 H.P
• 10.00 –2009 January
• 11.00–2010 Unified Functional Testing
• 11.5 –2012 Unified Functional Testing



Versions of QTP Versions of QTP Reviewed by Animesh Chatterjee on August 22, 2010 Rating: 5

HP - QTP lets learn basics

August 22, 2010
Today i was going through QTP overview through HP site... I saw few inportant aspect of QTP...
o QTP is an Object Based Testing Tool.
o QTP is for functional and Regression Testing.
o It follows Keyword driven approach.
o It supports Windows Operating Environment only.
o QTP Launched in 2002 (Nov). By Mercury Interactive. Later taken over by HP, in 2007.
o QTP has two types of License,
1. Seat or Node locked License,
2. Concurrent or float license.
Seat license for one system and Concurrent License, we can use for any system but one user at any time. If we want multiple concurrent licenses we can purchase.


o It supports GUI based (Graphical user interface) and Web based Applications Automation, does not support CUI (Command user interface) Applications.
o It has multilingual support. (It supports English, Chinese, Japanese, Korean, etc languages with respect to license.)
o It has adapted Microsoft Visual Basic Scripting edition for programming and excel like spread sheet for Data driven testing.
o SQL (Structured query language) embedded or inserted with QTP, so we can use SQL statements directly from QTP.
o It can be integrated with other Tools like WinRunner and Quality Center.
o It can be used for user interface (UI) test case automation and some limited (Non UI) Test case automation like File system operations and Data base operations.
o It was derived from Astra QuickTest (mother tool of QTP).
o It supports IE (Internet Explorer) only for recording tests, for execution it supports other browsers like Mozilla and AOL, opera Etc apart from IE.
o QTP is a Desktop Application (I-Tier/Stand alone).

o QTP has UNI code support.

Some of the notes are taken from GCREDDY's document ...
http://www.gcreddy.com/
HP - QTP lets learn basics HP - QTP lets learn basics Reviewed by Animesh Chatterjee on August 22, 2010 Rating: 5

Unsigned problem

August 15, 2010
Today i was sloving few white box testing related question i found this question from prasad's book...

i am not getting what could be the correct ans..

unsigned int x
.....
if (x<10)
{
....
}

question is if this above written code is snippet...find out the problem..
Unsigned problem Unsigned problem Reviewed by Animesh Chatterjee on August 15, 2010 Rating: 5
Powered by Blogger.