- onchange
- onclick
- ondblclick
- onblur
- onfocus
- onmousedown
- onmouseup
- onmouseover
- onmouseout
- onsubmit
- onreset
- onpropertychange
Automation Testing with QTP (Quick Test Professional), HP QTP, HP UFT, HP Unified Functional Testing
Thursday, November 10, 2011
How to use the FireEvent method when a click does not work
What is DOM? and How to use DOM properties in QTP?
The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM (such as its "Elements") may be addressed and manipulated within the syntax of the programming language in use. The public interface of a DOM is specified in its application programming interface (API).
how the browser display's objects in the browser
DOM
|-> Window
|-> Document
|-> Anchor
|-> Link
|-> Form
|-> Text-box
|-> Text Area
|-> Radio Button
|-> Check Box
|-> Select
|-> Button
QTP will be able to access to Internet Explorer Document Object Model (DOM) through which we will be able to access the HTML tags directly. Access to the DOM is performed using the .Object notation.
below function explains how to iterate all the tags in an Internet Explorer page. The function then outputs the inner-text of the tags (the text contained between the tags) to the Test Results using the Reporter object.
' we are using On Error Resume Next option because all the page elements might not have inner-text.
On Error Resume Next
Set Doc = Browser("CNN Interactive").Page("CNN Interactive").Object
' Loop through all the objects in the page.
For Each Element In Doc.all
TagName = Element.TagName ' Get the tag name.
InnerText = Element.innerText ' Get the inner text.
' Write the information to the test results.
Reporter.ReportEvent 0, TagName, InnerText
QTP 11 Now Supports Google Chrome
HP Patch QTPWEB_00088 features and limitations
HP just released a new patch QTPWEB_00088 that contains the following features and limitations:
QTP does not support recording steps in Google Chrome
Certain Google Chrome Javascript functionality, like web pages that use JSON objects, may cause unexpected behavior in QTP.
If you manually uninstalling the QTP agent extension from Tools>Extensions, you must manually reinstall it if you reinstall this patch.
Browser methods will not be supported
Also the following methods are not supported:
Browser.Home
Brpwser.Fulscreen
Browser.ClearCache
Browser.Objects
Running steps not supported:
Chrome: //* pages
Multiple tabs
Multiple browsers
Web pages that include frame sets
WebXML test objects
Web test objects located inside iFrame controls with a'blank' or 'about:blank 'SRC in property value
Developers Tools Pane but running against Google Chrome while the developers tools pane is open is supported
Web 2.0 test objects or Web Extensibility-based test objects
Web-based env, such as SAP Web, Siebel, Java, .NET Webforms etc..
Click here to Download QTPWEB_00088 Patch
Thanks to Joe for such valuable information http://www.joecolantonio.com/2011/11/02/qtp11-now-supports-google-chrome-patch-qtpweb_00088/
Friday, October 14, 2011
Close all Browsers Opened Except QC
Dim intIndex
Set oDesc=Description.Create
oDesc("micclass").Value="Browser"
intIndex=0
While Browser("micclass:=Browser","index:="&intIndex).exist(0) and intIndex<Desktop.ChildObjects(oDesc).count
If instr(1, Browser("micclass:=Browser","index:="&intIndex).getRoProperty("name"),"Quality Center") = 0 Then
SystemUtil.CloseProcessByHwnd( Browser("micclass:=Browser","index:="&intIndex).getRoProperty("hwnd"))
else
intIndex=intIndex+1
End if
wend
How to Search for a particular value in Excel ?
Using the below script, we will be able to search a particular value in the excel file.
*******************************************************************************************
Set appExcel = CreateObject("Excel.Application")
appExcel.visible=true
Set objWorkBook = appExcel.Workbooks.Open (filepath) 'opens the sheet
Set objSheet = appExcel.Sheets("Sheet1″)' To select particular sheet
With objSheet.UsedRange ' select the used range in particular sheet
Set c = .Find ("nn")' data to find
For each c in objSheet.UsedRange' Loop through the used range
If c="nn" then' compare with the expected data
c.Interior.ColorIndex = 40′ make the gary color if it finds the data
End If
Set c = .FindNext(c)' next search
next
End With
objWorkBook.save
objWorkBook.close
set appExcel=nothing
**********************************************************************************************
Thursday, October 13, 2011
Regular Expressions Utility Functions in VB Script
Below are the some of the very important functions using the regular expression in VB Script, which will make your Automation script creation very easy.
"********************************************************************************************
"'Function to check if a string matches a Regular Expression Pattern
"********************************************************************************************
Function IsRegExMatch(strText, regEx_Pattern, blnMatchCompleteString)
Dim oRegExp, retVal
'Create regular expression object.
Set oRegExp = New RegExp
'Set pattern.
oRegExp.Pattern = regEx_Pattern
'Ignore case
oRegExp.IgnoreCase = True
'Match complete string or not
oRegExp.Global = blnMatchCompleteString
'Test the regular expression
IsRegExMatch = oRegExp.Test(strText)
Set oRegExp = Nothing
End Function
"********************************************************************************************
"'Function to Match a Regular Expression and Replace with a particular text if a string matches a regular expression pattern.
"********************************************************************************************
Function RegExMatchandReplace(strText,regEx_Pattern,strReplacementText,blnMatchCompleteString)
Dim oRegExp, retVal,strReplacedText
' Create regular expression object.
Set oRegExp = New RegExp
'Set pattern.
oRegExp.Pattern = regEx_Pattern
'Ignore case
oRegExp.IgnoreCase = True
'Match complete string or not
oRegExp.Global = blnMatchCompleteString
'Test the regular expression
RegExMatch = oRegExp.Test(strText)
If RegExMatch = True Then
strReplacedText = oRegExp.Replace(strText,strReplacementText)
End If
RegExMatchandReplace = strReplacedText
Set oRegExp = Nothing
End Function
"********************************************************************************************
"'Function to Get Total Number of Matches of a Regular Expression Pattern in a particular string
"********************************************************************************************
Function GetRegExMatchCount(strText, regEx_Pattern, blnMatchCompleteString)
Dim oRegExp, retVal
'Create regular expression object.
Set oRegExp = New RegExp
'Set pattern.
oRegExp.Pattern = regEx_Pattern
'Ignore case
oRegExp.IgnoreCase = True
'Match complete string or not
oRegExp.Global = blnMatchCompleteString
'Test the regular expression
RegExpMatch = oRegExp.Test(strText)
If RegExpMatch Then
Set oRegExMatchCount = oRegExp.Execute(strText)
GetRegExMatchCount = oRegExMatchCount.Count
End If
Set oRegExp = Nothing
End Function
"********************************************************************************************
"'Function to Trim white space characters from end of a string
"********************************************************************************************
Public Function RTrimW(ByVal Text)
'String pattern ending with carriage return, tab, new line or a space character
RTrimPattern = "[\s]*$"
Dim oRegExp
Set oRegExp = New RegExp
oRegExp.Pattern =RTrimPattern
oRegExp.Global = False
RTrimW = oRegExp.Replace(Text,"")
Set oRegExp = Nothing
End Function
"********************************************************************************************
"'Function to Trim white space characters from start of a string
"********************************************************************************************
Public Function LTrimW(ByVal Text)
'String pattern ending with carriage return, tab, new line or a space character
LTrimPattern = "^[\s]*"
Dim oRegExp
Set oRegExp = New RegExp
oRegExp.Pattern = LTrimPattern
oRegExp.Global = False
LTrimW = oRegExp.Replace(Text,"")
Set oRegExp = Nothing
End Function
"********************************************************************************************
"Function to Trim white space characters from both start and end of a string
"********************************************************************************************
Public Function TrimW(ByVal Text)
TrimW = LTrimW(RTrimW(Text))
End Function
"********************************************************************************************
Thursday, October 6, 2011
QTP Tricky Questions And Answers
- How will you automate a window which while spying is not returning any property value??
- How do you find the color and font of all the links on the page???
- What are the disadvantages of smart identification??
- What are the disadvantages of recovery scenario??
- How can you execute JavaScript on QTP??
- What are the basic prerequisites required in automating an Infragistics controls based application?
- Can I record a web based application on Mozilla??
- What is the difference between Repository Parameter and Repositories Collection??
- How to copy Virtual Object Manager from one computer to another computer??
- Can we use GetRoProperty method to get index or location of link in web application??
- Open HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration_UI\ScriptMgr
- Create a new String value with name AltProgID and value "Mercury.JSScriptMgr" and change the value of "Create" to 1
- Create a new child key inside the key HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration_UI\ScriptConstants {0ECD5785-BE7D-11d4-8EAF-11135659EC56}
- Repeat the same steps for the below key HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Configuration
- Open C:\Program Files\Mercury Interactive\QuickTest Professional\bin\QTEditor.ini
- Add the below parameter to [General options] AllowJavaScript = 1 DisableVBScript = 1
- Done
Friday, September 2, 2011
How to connect to Quality Center form Quick Test Professional
Advantages of Quality Center:
Quality Center is a single application for complete Test ManagementStarts with Requirements, goes through Test Planning and Test Execution, and on through Defects.Each of these items can be linked or associated with each other.
How to connect to QC form QTP:
with the below simple steps and pictures you will be able to see how we can connect to QC from QTP
1. Open file menu and click on to QC connection and give the QC server url.
2. Give the user credentials, select the domain, project and close the window
All about QTP Descriptive Programming
Since Object repository will be stored in centralized place, property definition for any Object can be easily changed at any time if the application developer changes the property of the actual object/control.
Gmail login script will be used in many test scenarios.
In case of Object Repository, you and your team member will be forced to use same object description for login page controls/Objects (e.g username, password, login button).
Thursday, September 1, 2011
Understanding QTP License Types
1. Seat License
2. Concurrent License
A trial version of the software is also available for 14 days
Seat License:A seat license is specific to the computer on which it is installed. This license includes a 14-day demo period.
Concurrent License:A concurrent license regulates the number of concurrent HP QTP users and requires installation of a license server from a separate CD-ROM found in the HP QTP package. Concurrent license is purchased seperately from HP and installed on the HP Functional testing Concurent License Server.
Tuesday, August 30, 2011
How to find DataType of a Variable with VBScript?
1. Vartype
2. Typename
Vartype returns a numeric value indicating the sub datatype of a variable.
The below table contains return values that indicate respective subtypes.
Return Value
|
SubDatatype
|
Description
|
0
|
vbEmpty
|
Empty (uninitialized)
|
1
|
vbNull
|
Null (no valid data)
|
2
|
vbInteger
|
Integer
|
3
|
vbLong
|
Long integer
|
4
|
vbSingle
|
Single-precision floating-point number
|
5
|
vbDouble
|
Double-precision floating-point number
|
6
|
vbCurrency
|
Currency
|
7
|
vbDate
|
Date
|
8
|
vbString
|
String
|
9
|
vbObject
|
Automation object
|
10
|
vbError
|
Error
|
11
|
vbBoolean
|
Boolean
|
12
|
vbVariant
|
Variant (used only with arrays of Variants)
|
13
|
vbDataObject
|
A data-access object
|
17
|
vbByte
|
Byte
|
8192
|
vbArray
|
Array
|
Ex:
Dim x
x=10
msgbox vartype(x) 'Returns 2
In the above table 2 indicates vbInteger datatype.So x is an integer type.
Typename directly returns the name of the Sub Datatype of a variable.
SubDatatype
|
Description
|
Byte
|
Byte value
|
Integer
|
Integer value
|
Long
|
Long integer value
|
Single
|
Single-precision floating-point value
|
Double
|
Double-precision floating-point value
|
Currency
|
Currency value
|
Decimal
|
Decimal value
|
Date
|
Date or time value
|
String
|
Character string value
|
Boolean
|
Boolean value; True or False
|
Empty
|
Unitialized
|
Null
|
No valid data
|
< object type >
|
Actual type name of an object
|
Object
|
Generic object
|
Unknown
|
Unknown object type
|
Nothing
|
Object variable that doesn't yet refer to an object instance
|
Error
|
Error
|
Ex:
Dim x
x=10
msgbox typename(x) 'Returns “Integer”
There are some more VBScript Built-in functions to find whether a variable datatype is specific datatype or not.
IsArray -- Returns a Boolean value indicating whether a variable is an array or not.
IsDate -- Returns a Boolean value indicating whether an expression can be converted to a date.
IsEmpty -- Returns a Boolean value indicating whether a variable has been initialized.
IsNull -- Returns a Boolean value that indicates whether an expression contains no valid data (Null).
IsNumeric -- Returns a Boolean value indicating whether an expression can be evaluated as a number.
IsObject -- Returns a Boolean value indicating whether an expression references a valid Automation object.
Built in functions are available for only these datatypes. You can write built function for every datatype like below…
'@@@@@@@@@@@@@@@@@@@@@@
Function IsString(oValue)
If vartype(oValue)=8 then
IsString=true
Else
IsString=False
End If
End Function
'@@@@@@@@@@@@@@@@@@@@@@
Monday, August 29, 2011
How do I sort arrays items using vbscript?
' declaring the array
Dim arrSortOut(10)
' assigning data to the array
arrSortOut(0)="Ammu"
arrSortOut(1)="Siva"
arrSortOut(2)="Madhu"
arrSortOut(3)="Ranga"
arrSortOut(4)="Jagadesh"
arrSortOut(5)="Kumar"
arrSortOut(6)="Praveen"
arrSortOut(7)="Martha"
arrSortOut(8)="Zeebra"
arrSortOut(9)="123Zeebra"
arrSortOut(10)="!123Zeebra"
for i = UBound(arrSortOut) - 1 To 0 Step -1
for j= 0 to i
if arrSortOut(j)>arrSortOut(j+1) then
temp=arrSortOut(j+1)
arrSortOut(j+1)=arrSortOut(j)
arrSortOut(j)=temp
end if
next
next
for x=0 to 8 UBound(arrSortOut)
msgbox arrSortOut(x)' to check the items
next
How to Maximize/Minimize a Browser?
If Browser("abc").Exist Then
Brw_Hwnd = Browser("abc").GetROProperty("hwnd")
Set a= Description.Create
a("hwnd").Value = Brw_Hwnd
Window(a).Maximize'to maximize application browser
'Window(a).Minimize' to minimize application browser
End If
How to get Tool tip of Images in a web page?
Browser("abc").Page("abc").Sync
Set desc_img = Description.Create
desc_Img("html tag").value = "IMG"
Set list_imgs= Browser("abc").Page("abc").ChildObjects(desc_img)
For i = 0 To list_imgs.Count - 1
tool_tiptxt= list_imgs(i).GetROProperty("alt")
If tool_tiptxt <> "" Then
MsgBox "Tool tip text= " & tool_tiptxt
End If
Next
How to get the font color of an item in a WebList ?
set Web_list_Items= Browser("abc").Page("abc").WebList("abc").Object.all.tags("option")
For each element in Web_list_Items
Set style = element.currentstyle
Item_text_color=style.Color
Item_text=element.text
msgbox Item_text_color
msgbox Item_text
Next
Friday, August 26, 2011
Action Template in QTP
Every time you open New script in QTP you will get a blank window in Expert view, but if you want to view the Standard header commented section with the automation Standards, you can create a Template which you can use for all the scripts to view the same set of instructions/Standards, and also you can pass all other team members to use the same.
Just follow the bellow simple steps to create Action Templete....
1. Create a text file with what all things need to be in the script.
2. Save as this text file as ActionTemplate.mst file in the
C:\Program Files\hp\QuickTest Professional\dat Folder.
3. Now Click on new script in QTP.
You will get what ever text you have kept in the template !!!!!
Scripting Guidelines or Coding Standards in Test Automation Script
The main motive for using a regular set of coding Standards is to normalize the structure and coding way of a QTP script or set of scripts, so that you and others team members can easily read and understand the QTP code.
Using good coding standards will results in accurate, readable, and unmistakable QTP Script.
Code that is consistent with other languages like Java script etc,. conventions and as sensitive as possible.
Script Organization
An example of the comment block is as follows:
you can also create a action template, with fallowing information, href="http://automationwithqtp.blogspot.com/2011/08/action-template-in-qtp.html">Click Here to see how to create a action template in QTP.
'Test Script Header
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'@Script Name : < Name of the Script>
'@Script Description : < Description of the Script>
'@Script Author : < Jr.Siva Kumar Eanuga>
'@Email ID: < Shivakumar004@gmail.com>
'@CreationDate : < dd-mm-yyyy>
'@Last Updated Date : < dd-mm-yyyy>
'@PreCondition : < pre requisites to be used for the script>
'@Libraries : < required library files>
'@External Function Reference:
'@DataFiles : < required data files>
'@DtParam : < Name>
'@DtParam : < Name>
'@DtParam : < Name>
'@Modification : < By
'@Description: < modification description>
'@Reviewed By : < Sr. Siva Kumar Eanuga>
'@Reviewed Date : < dd-mm-yyyy>
'@Remarks : < Additional information>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'-- Constant Declarations
'declare here your constants
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'--- Global Variable Declarations
'declare here your Global Variables
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'--- Local Variable Declarations
'declare here your Local Variables
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'< detailed script>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' The End of Script
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Standards of Constant Naming
Constant names should be uppercase with underscores (_) between words.Ex: USER_LIST_MAX, NEW_LINE
Standards of Variable Naming
For easy readability purpose use the prefixes like below examples, along with descriptive names for variables in your QTP Script code.Ex:
String -- sName
Object -- oObjectname
Integer, Byte, Long -- nNumber
Array -- arrListitems
Boolean -- bYes
Single, Double -- fPrice
DateTime -- dToday
Error -- errResponse
Currency –- cRupees
Object Naming Standards
For the objects we create in the QTP script, we use prefix “o” (small letter o).Ex:
ADODB.Connection -- oConn
ADODB.Recordset -- oRset
Scripting.xmlobject -- oXmlobj
Scipting.FileSystemObject -- oFsobj
Scipting.TextStream -- oTxt
Scripting.Dictionary -- oDic
Shell.Application -- oWsh
Excel.Application -- oXls
to be continued .....
Thursday, August 25, 2011
How to get Sub-folders Count and Names from a Folder?
'Creating a file system object
Set Obj1 = Obj.GetFolder("C:\test")
Set Obj2 = Obj1.SubFolders
msgbox Obj2.Count 'displaying count of sub-folders
Fold_names = Fold_names& Fold_Iteam.name &vbnewline
msgbox Fold_names 'Displaying all sub-folders names
Lock your system after execution of your QTP Script
Set obj = CreateObject("WScript.Shell")
sCmnd = "%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation"
obj.Run sCmnd, 0, False
End Function
Tuesday, August 23, 2011
HP QTP Certification
Download Here
and you can follow the simple instructions.The cost of the HP QTP certification now is $150.Quick Test Professional 11.00
ØManage Your Test Data
- Unbind your data from your tests
- Share common data sources across different tests
- Filter your data to fit your testing needs
- Increase requirements traceability
Ø Test Your GUI and UI-Less Application Functionality in One Test
Ø Collaborate with Developers to Pinpoint Defects Using Log Tracking
QuickTest's new Log Tracking functionality helps to work with developers to pinpoint the root causes of unexpected behavior of the application during run time.
Ø Out-of-the-Box Support for Web 2.0 Toolkit Applications
Ø Automatically Parameterize Steps
Ø Extend WPF and Silverlight Support
Ø Load Function Libraries at Run Time