About Me

Gaurav Seth is a a Senior Automation Test Analyst with experience in QTP, Selenium and Ranorex tools and currently working on Automating in C# for a FX trading Client

Windows Scripting

There are some Web/Windows objects which will perform actions when certain key commands, such as CTRL+SHIFT+ESC are entered. These Web/Windows objects do not have a type method associated with them that can be used to replay these keys. In these cases you can use SendKeys method to send keyboard input to your application.
Download and install the Windows Scripting Host.

1. Create a WScript.Shell object.
2. Activate the browser in which you want to execute the keys.
3. Use the SendKeys method to type the key combination.

Example:

' This code executes the CTRL+F key combination (search) on a browser.
Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "Put the label of the browser" ' Activate the browser window
wait(3)
WshShell.SendKeys "^f" ' The caret (^) represents the CTRL key.
wait(2)
The SendKeys method will send keystroke(s) to the active window. To send a single character (for example, x), use "x" as the string argument. To send multiple characters (for example, abc), use "abc" as the string argument. You can also send special characters such as SHIFT, CTRL, and ALT, which are represented by the plus sign (+), the caret (^), and the percent sign (%), respectively.



' Below Piece of Snippet will Type in the notepad

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "Notepad"
WshShell.AppActivate "Notepad"
wait (3)
WshShell.SendKeys "x"

'Below Piece of code will open the Page Setup from the Notepad

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "Notepad"
WshShell.AppActivate "Notepad"
wait (3)
WshShell.SendKeys "%f"
WshShell.SendKeys "{Down}"
WshShell.SendKeys "{Down}"
WshShell.SendKeys "{Down}"
WshShell.SendKeys "{Down}"
WshShell.SendKeys "{Enter}"

Delete browser Cookies

We can use WebUtil.(Method)

webutil.DeleteCookie
or

webutil.DeleteCookies

Automating MS Word Documents

Following Snippet will inform you how to add a Text to the Tables in the Word document.

Set oWord = CreateObject("Word.Application")
oWord.Visible = True

Set oDoc = oWord.Documents.Add()
Set oRange = oDoc.Range()
oDoc.Tables.Add oRange,1,3
Set objTable = oDoc.Tables(1)
objTable.style = "Table Grid"

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Process")

nRow = 1
objTable.Cell(nRow, 1).Range.Font.Bold = True
objTable.Cell(nRow, 1).Range.Text = "Process"
objTable.Cell(nRow, 2).Range.Font.Bold = True
objTable.Cell(nRow, 2).Range.Text = "Description"
objTable.Cell(nRow, 3).Range.Font.Bold = True
objTable.Cell(nRow, 3).Range.Text = "Path"

For Each objItem in colItems

nRow = nRow + 1
objTable.Rows.Add()
objTable.Cell(nRow, 1).Range.Font.Bold = True
objTable.Cell(nRow, 1).Range.Text = objItem.Name
objTable.Cell(nRow, 2).Range.text = objItem.Description
If objItem.Executablepath <> "" then objTable.Cell(nRow, 3).Range.text = objItem.Executablepath
Next

QTP - Menu bar / Menu Items missing

To enable missing items or display all menu items in the menu bar, follow the following steps:-

1. Go to Start page of QTP
2. Go to Tools-->Options
3. In the general section, click on Restore Layout button.

VB Scripting with QTP Part 2

Below Snippet of code will let you know if a particular Windows Process is running in the Background or not. From windows Task manager just put the Process name in the If Condition in Upper Case

Dim AllProcess
Dim Process
Dim strFoundProcess
strFoundProcess = False
Set AllProcess = getobject("winmgmts:") 'create object
For Each Process In AllProcess.InstancesOf("Win32_process") 'Get all the processes running in your PC
If (Instr (Ucase(Process.Name),"EXCEL.EXE") = 1) Then 'Made all uppercase to remove ambiguity. Replace TASKMGR.EXE with your application name in CAPS.
msgbox "Application is already running!" 'You can replace this with Reporter.ReportEvent
strFoundProcess = True
Exit for
End If
Next
If strFoundProcess = False Then
msgbox "Go ahead!Application is not running" 'You can replace this with Reporter.ReportEvent
End If
Set AllProcess = nothing

Using Description.Create() Object to Activate a Window. This will activate a VB Window with title having SIREN title. After that Counting the No of buttons on this window using Description.Create()

Set FrmActivate=Description.Create()
FrmActivate("micclass").Value="vBWindow"
FrmActivate("Text").Value="SIREN"
FrmActivate.Activate

Set btn=Description.Create()
btn(“micclass”).Value=”VbButton”
btn(“Text”).Value=”OK”

Set cnt=VBWindow(FrmActivate).ChildObjects(btn)
Msgbox cnt.Count

or Msgbox vbWindow(FrmActivate).ChildObjects(bnt).Count

To See the name of all the buttons present in the VB WIndow use the Following code

Set FrmActivate=Description.Create()
FrmActivate("micclass").Value="VbWindow"
FrmActivate("Text").Value="SIREN"

Set btn=Description.Create()
btn("micclass").Value="VbButton"

Set cnt=VbWindow(FrmActivate).ChildObjects(btn). Count
Set val=VBWindow(FrmActivate).ChildObjects(btn)
For i=0 to cnt-1
value=val(i).GetRoProperty(“Text”)
msgbox value
Next


How to open a URL in the Maximize State
url="www.gmail.com"
Set IEInstance=CreateObject("InternetExplorer.Application")
IEInstance.Visible=True
IEInstance.Navigate(url)
Window("hwnd:=" &IEInstance.HWND).Maximize

Below piece of snippet code will demonstrate how to count no and item name of drop down items from the WebList

SystemUtil.Run "http://newtours.demoaut.com/"
Browser("title:= Welcome: Mercury Tours" ).Sync
Browser("title:= Welcome: Mercury Tours" ).Page("title:= Welcome: Mercury Tours").WebEdit("index:=0").Set "mercury"
Browser("title:= Welcome: Mercury Tours" ).Page("title:= Welcome: Mercury Tours").WebEdit("index:=1").Set "mercury"
Browser("title:= Welcome: Mercury Tours" ).Page("title:= Welcome: Mercury Tours").Image("file name:=btn_signin.gif").Click
Browser("title:=Find a Flight: Mercury Tours:").Sync
'Browser("title:= Find a Flight: Mercury Tours:" ).Page("title:= Find a Flight: Mercury Tours:").WinButton("x:=455,y:=463, text:=View Calendar, index:=1, hwnd:=8196244").Click
Set webl=Description.Create()
webl("micclass").Value="WebList"
webl("name").Value="fromPort"
Dim wl
Set wlc=Browser("title:= Find a Flight: Mercury Tours:" ).Page("title:= Find a Flight: Mercury Tours:").ChildObjects(webl)
wl= Browser("title:= Find a Flight: Mercury Tours:" ).Page("title:= Find a Flight: Mercury Tours:").WebList(webl).GetROProperty("items count")
witems=Browser("title:= Find a Flight: Mercury Tours:" ).Page("title:= Find a Flight: Mercury Tours:").WebList(webl).GetROProperty("all items")
msgbox witems
t=Split(witems, ";")
For i=0 to ubound(t)
msgbox t(i)
Next
Browser("title:= Find a Flight: Mercury Tours:" ).Page("title:= Find a Flight: Mercury Tours:").Image("file name:=continue.gif").Click


Following Snippet of Code will tell you how you
1. How to Use Index property to uniquely identify the Items such as WebList(drop down items), WebCheckBox(CheckBox), WebEdit
2. How to take a screenshot of the Application

SystemUtil.Run "http://newtours.demoaut.com/"
Browser("title:= Welcome: Mercury Tours" ).Sync
Browser("title:= Welcome: Mercury Tours" ).Page("title:= Welcome: Mercury Tours").WebEdit("index:=0").Set "mercury"
Browser("title:= Welcome: Mercury Tours" ).Page("title:= Welcome: Mercury Tours").WebEdit("index:=1").Set "mercury"
Browser("title:= Welcome: Mercury Tours" ).Page("title:= Welcome: Mercury Tours").Image("file name:=btn_signin.gif").Click
Browser("title:=Find a Flight: Mercury Tours:").Sync
Browser("title:= Find a Flight: Mercury Tours:" ).Page("title:= Find a Flight: Mercury Tours:").Image("file name:=continue.gif").Click
Browser("title:= Select a Flight: Mercury Tours" ).Page("title:= Select a Flight: Mercury Tours").Image("file name:=continue.gif").Click
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebList("index:=0").Select "Bland"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebCheckBox("index:=0").Set "OFF"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebCheckBox("index:=1").Set "ON"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=0").Set "Gaurav"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=1").Set "Seth"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=2").Set "987698689"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=3").Set "Gaurav"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=4").Set "Kumar"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=5").Set "Seth"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=6").Set "16 Dashmesh Avenue"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=8").Set "Amritsar"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=9").Set "Punjab"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=10").Set "143104"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=11").Set "Sheetla Mata Road"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=13").Set "Gurgaon"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=14").Set "Haryana"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").WebEdit("index:=15").Set "145003"
Desktop.CaptureBitmap "C:\QTP\Screenshots\Bookaflight.PNG"
Browser("title:= Book a Flight: Mercury Tours" ).Page("title:= Book a Flight: Mercury Tours").Image("file name:=purchase.gif").Click


Print Statement

Displays information in the QuickTest Print Log window during the run session. The QuickTest Print Log window remains open while the run session continues, until you close it.

Set webl=Description.Create()
webl("micclass").Value="WebList"
webl("name").Value="fromPort"
Dim wl
Set wlc=Browser("title:= Find a Flight: Mercury Tours:" ).Page("title:= Find a Flight: Mercury Tours:").ChildObjects(webl)
wl= Browser("title:= Find a Flight: Mercury Tours:" ).Page("title:= Find a Flight: Mercury Tours:").WebList(webl).GetROProperty("items count")
Print "The total no of items are "&wl
witems=Browser("title:= Find a Flight: Mercury Tours:" ).Page("title:= Find a Flight: Mercury Tours:").WebList(webl).GetROProperty("all items")
Print " The Items are "&"\n"& witems
t=Split(witems, ";")
For i=0 to ubound(t)
Print "The drop down item is " &t(i)



To count no of Tables in a web Page, get the cell data of the Tables and cofirming the existence of particular text in them

Set mypage=Browser("title:= Flight Confirmation: Mercury Tours" ).Page("title:= Flight Confirmation: Mercury Tours")

Set table_desc=Description.Create()
table_desc("html tag").Value="TABLE"

Set all_tables=mypage.ChildObjects(table_desc)
table_count=cint(all_tables.count)

msgbox table_count
Print "We have" &table_count &"tables opened in the current Browser"

For icount=0 to table_count-1
Print "Table No" &icount+1
For irowcount=1 to all_tables(icount).RowCount
For icolumnCount=1 to all_tables(icount).ColumnCount(irowcount)
cell_value=all_tables(icount).getcelldata(irowcount,icolumnCount)
Print "Cell Value is " & cell_value

If instr(1,cell_value,"Flight Confirmation" )Then
Print "Sucess!!!!!!!!!!!!!!!!!!!!!!!"
End If

Next
irowcount=irowcount+1
Next
Next

DataTable Importsheet and Exportsheet Methods

DataTable.ImportSheet "C:\QTP\SystmOne_Config_Files\1.xls",1,1

DataTable.ExportSheet "C:\QTP\SystmOne_Config_Files\3.xls",1

DataTable Count Rows and Columns

DataTable.ImportSheet "C:\QTP\SystmOne_Config_Files\2.xls" ,1 ,1

a=DataTable.GetSheet(1).GetRowCount()
b=DataTable.GetSheet(1).GetParametercount()


Regular Expressions used to find a pattern of Text. For Example time in the format
aa:bb:cc in a particular page



Dim ObjRegExp, IEinstance
Set IEinstance =CreateObject("InternetExplorer.Application")
IEinstance.Visible=True
Wait(2)
IEinstance.Navigate "http://www.timeanddate.com/worldclock/"
Wait(2)

lvVal = IEinstance.Document.body.innertext

Dim Searchkeys(4)
Searchkeys(0)="[0-9]{2}\:[0-9]{2}\:[0-9]{2}"
cnt=0


If SearchKeys(0) <> "" Then

Set ObjRegExp = new regexp
ObjRegExp.pattern = SearchKeys(0)
ObjRegExp.Global = True
ObjRegExp.Ignorecase = True
Set matches = ObjRegExp.Execute(lvVal)
For each objmatch in matches
cnt = cnt+1
tmpVar = objmatch.value
Print objmatch.value

Next
Else
End If

Search a string pattern from web page.
Use the Above code just modify the below

If you use Searchkeys(0) as "[a-z]{2} [a-z]{9} [a-z]{12}" and use IEinstance.Navigate "http://hpqtpautomation.blogspot.com/"
then this will extract the String " HP QuickTest Professional" from this web page.

Regular Expressions

What is a Regular Expression

A regular expression is a pattern of text that consists of ordinary characters (for example, letters a through z) and special characters, known as metacharacters. The pattern describes one or more strings to match when searching a body of text. The regular expression serves as a template for matching a character pattern to the string being searched.

A regular expression is a string that describes or matches a set of strings. It is often called a pattern as it describes set of strings.

Given underneath is one of the most widely used and ever confused BackLash character. The remaining expressions are serialized below that

A backslash (\) instructs QuickTest to treat the next character as a literal character, if it is otherwise a special character. The backslash (\) can also instruct QuickTest to recognize certain ordinary characters as special characters. For example, QuickTest recognizes \n as the special newline character.
For example:
w matches the character w
\w is a special character that matches any word character including underscore
For example, in QTP, while entering the URL of a website,
http://mercurytours.mercuryinteractive.com
The period would be mistaken as an indication of a regular expression. To indicate that the period is not part of a regular expression, you would enter it as follows:
mercurytours\.mercuryinteractive\.com Note: If a backslash character is used before a character that has no special meaning, the backslash is ignored. For example, \z matches z.


Few Snippets involving Regular Expressions


Regular Express1.vbs . This function regular expression will match a string/value/pattern out of Strings
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
RetStr = RetStr & "Match found at position "& Match.FirstIndex & " Match Value is " & Match.Value & VBCRLF
Next
RegExpTest = RetStr
End Function
MsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))

You can also return the value that the calling function back to a variable and then print it as follows
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
RetStr = RetStr & "Match found at position "& Match.FirstIndex & " Match Value is " & Match.Value & VBCRLF
Next
RegExpTest = RetStr
End Function
RetStr = RegExpTest("is.", "IS1 is2 IS3 is4")
Msgbox RetStr

Regular Expressions to Search from strings(Keywords) from Internet Explorer page stored on desktop

Dim ObjRegExp, IEinstance
Set IEinstance =CreateObject("InternetExplorer.Application")
cnt=1
IEinstance.Navigate "C:\Documents and Settings\gseth\Desktop\Gmail.htm"
IEinstance.visible=true
lvVal = IEinstance.Document.body.innertext
msgbox “ The Contents of Gmail are “ &lvVal
Dim Searchkeys(5000)
Searchkeys(0) ="Create an Account"
Searchkeys(1)="Gmail"
Searchkeys(2)="Google"

For keyval = 0 to ubound(SearchKeys)
Found = False
If SearchKeys(keyval) <> "" Then
'Msgbox "Searching for " & SearchKeys(keyval)
Set ObjRegExp = new regexp
ObjRegExp.pattern = SearchKeys(keyval)
ObjRegExp.Global = True
ObjRegExp.Ignorecase = True
Set matches = ObjRegExp.Execute(lvVal)
For each objmatch in matches
tmpVar = objmatch.value
If SearchKeys(keyval) = CStr(tmpVar) Then
Msgbox "Count is " &cnt & " Matching value is " &tmpVar
cnt = cnt+1
End If
Next

Else
Exit For
End If
Next
IEinstance.Quit
Set IEinstance = Nothing

Regular Expression for Searching a keyword from the Text File (Notepad File) and displaying it

Dim ObjRegExp,objFSO, objReadFile, contents,var
Const conForReading=1

Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objReadFile=objFSO.OpenTextFile("C:\Documents and Settings\kdhote.SHALL20-1\Desktop\VB Scripting Code Snippets.txt", 1 , False)
contents=objReadFile.ReadAll
msgbox " the contents are" &contents
var="October"
Set ObjRegExp = new regexp
ObjRegExp.pattern = var
ObjRegExp.Global = True
ObjRegExp.Ignorecase = True
Set matches = ObjRegExp.Execute(contents)
For each objmatch in matches
tmpVar = objmatch.value
If var = CStr(tmpVar) Then
Msgbox "Count is " &cnt & " Matching value is " &tmpVar
cnt = cnt+1
End If
Next

Set objFSO=Nothing
Set objReadFile=Nothing



Expressions & Explanation
Special characters and sequences are used in writing patterns for regular expressions. The following describes the characters and sequences that can be used.


\
Marks the next character as either a special character or a literal. For example, "n" matches the character "n". "\n" matches a newline character. The sequence "\\" matches "\" and "\(" matches "(".

^
Matches the beginning of input.

$
Matches the end of input.

*
Matches the preceding character zero or more times. For example, "zo*" matches either "z" or "zoo".

+
Matches the preceding character one or more times. For example, "zo+" matches "zoo" but not "z".

?
Matches the preceding character zero or one time. For example, "a?ve?" matches the "ve" in "never".

.
Matches any single character except a newline character.

(pattern)
Matches pattern and remembers the match. The matched substring can be retrieved from the resulting Matches collection, using Item [0]...[n]. To match parentheses characters ( ), use "\(" or "\)".

xy
Matches either x or y. For example, "zwood" matches "z" or "wood". "(zw)oo" matches "zoo" or "wood".

{n}
n is a nonnegative integer. Matches exactly n times. For example, "o{2}" does not match the "o" in "Bob," but matches the first two o's in "foooood".

{n,}
n is a nonnegative integer. Matches at least n times. For example, "o{2,}" does not match the "o" in "Bob" and matches all the o's in "foooood." "o{1,}" is equivalent to "o+". "o{0,}" is equivalent to "o*".

{n,m}
m and n are nonnegative integers. Matches at least n and at most m times. For example, "o{1,3}" matches the first three o's in "fooooood." "o{0,1}" is equivalent to "o?".

[xyz]
A character set. Matches any one of the enclosed characters. For example, "[abc]" matches the "a" in "plain".

[^xyz]
A negative character set. Matches any character not enclosed. For example, "[^abc]" matches the "p" in "plain".

[a-z]
A range of characters. Matches any character in the specified range. For example, "[a-z]" matches any lowercase alphabetic character in the range "a" through "z".

[^m-z]
A negative range characters. Matches any character not in the specified range. For example, "[m-z]" matches any character not in the range "m" through "z".

\b
Matches a word boundary, that is, the position between a word and a space. For example, "er\b" matches the "er" in "never" but not the "er" in "verb".

\B
Matches a non-word boundary. "ea*r\B" matches the "ear" in "never early".

\d
Matches a digit character. Equivalent to [0-9].

\D
Matches a non-digit character. Equivalent to [^0-9].

\f
Matches a form-feed character.

\n
Matches a newline character.

\r
Matches a carriage return character.

\s
Matches any white space including space, tab, form-feed, etc. Equivalent to "[ \f\n\r\t\v]".

\S
Matches any nonwhite space character. Equivalent to "[^ \f\n\r\t\v]".

\t
Matches a tab character.

\v
Matches a vertical tab character.

\w
Matches any word character including underscore. Equivalent to "[A-Za-z0-9_]".

\W
Matches any non-word character. Equivalent to "[^A-Za-z0-9_]".

\num
Matches num, where num is a positive integer. A reference back to remembered matches. For example, "(.)\1" matches two consecutive identical characters.

\n
Matches n, where n is an octal escape value. Octal escape values must be 1, 2, or 3 digits long. For example, "\11" and "\011" both match a tab character. "\0011" is the equivalent of "\001" & "1". Octal escape values must not exceed 256. If they do, only the first two digits comprise the expression. Allows ASCII codes to be used in regular expressions.

\xn
Matches n, where n is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, "\x41" matches "A". "\x041" is equivalent to "\x04" & "1". Allows ASCII codes to be used in regular expressions.



Why are Regular Expressions important in QTP

In order to carry out tests in QTP each and every objects are searched in the object repository (OR). An object in a real time application sometime has properties that keep changing from time to ti for which at the time of execution the script fails. To overcome this, regular expressions are used for that object’s particular dynamic property.

How to create Regular Expressions in QTP

Below Link is very useful for explaining how to create regular expressions in QTP

http://www.cinterviews.com/2010/10/to-create-regular-expression-in-qtp.html

Below are couple of Youtube Links of Regular Expressions


Introduction to Regular Expressions Part 1
http://www.youtube.com/watch?v=Au6ghl57ovc

Introduction to Regular Expressions Part 2
http://www.youtube.com/watch?v=MgnIFM0H9dk&NR=1

Screenshots - Framework Developed in CSC











VB Scripting with QTP Part 1

Below are the List of Few VB Scripting Functions


Left
Dim MyString, LeftString
MyString = "VBSCript"
LeftString = Left(MyString, 3)
msgbox LeftString

StrReverse
Dim MyStr
MyStr = StrReverse("VBScript")
msgbox MyStr

TIMER
a=Msgbox (TimeIt(10))
Function TimeIt(N)
Dim StartTime, EndTime
StartTime = Timer
For I = 1 To N
Next
EndTime = Timer
TimeIt = EndTime - StartTime
End Function

Right
Dim AnyString, MyStr1,MyStr2,MyStr3
AnyString = "Hello World" ' Define string.
MyStr1 = Right(AnyString, 1) ' Returns "d".
MyStr2 = Right(AnyString, 6) ' Returns " World".
MyStr3 = Right(AnyString, 20) ' Returns "Hello World".
msgbox MyStr1 & " " & MyStr2 &" " &MyStr3

Rnd for Randomize
Dim a, i
for i =1 to 10
a =Int((1000 - 50 + 1) * Rnd + 50)
msgbox a
next

randomize.vbs
a=Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
msgbox a

Join.vbs
Dim MyString
Dim MyArray(3)
MyArray(0) = "Mr."
MyArray(1) = "John "
MyArray(2) = "Doe "
MyArray(3) = "III"
MyString = Join(MyArray)
msgbox MyString

InputBox.vbs
Dim Input
Input = InputBox("Enter your name")
MsgBox ("You entered: " & Input)

Do while.vbs
Dim Check, Counter
Check = True: Counter = 0
Do
Do While Counter < 20
Counter = Counter + 1
If Counter = 10 Then
Check = False
Exit Do
End If
Loop
Loop Until Check = False

Len.VBS
Dim MyString
MyString = Len("VBSCRIPT") ' MyString contains 8.
Msgbox MyString

split.vbs
Dim MyString, MyArray, Msg
MyString = "VBScriptXisXfun!"
MyArray = Split(MyString, "x", -1, 1)
' MyArray(0) contains "VBScript".
' MyArray(1) contains "is".
' MyArray(2) contains "fun!".
Msg = MyArray(0) & " " & MyArray(1)
Msg = Msg & " " & MyArray(2)
MsgBox Msg

Replace.vbs
Dim MyString1
MyString1 = Replace("kapy", "p", "Y")
MyString2 = Replace("PANT", "P", "X")
msgbox MyString1
msgbox MyString2

ccur.vbs
Dim MyDouble, MyCurr
MyDouble = 543.214588 ' MyDouble is a Double.
MyCurr = CCur(MyDouble * 2) ' Convert result of MyDouble * 2 (1086.429176) to a Currency (1086.4292).
msgbox MyCurr

Msgbox
Dim MyVar
MyVar = MsgBox ("Hello World!", 65, "MsgBox Example")

RGB.vbs
Function RevRGB(red, green, blue)
RevRGB= CLng(blue + (green * 256) + (red * 65536))
msgbox RevRGB
End Function

Time.vbs
Dim MyTime
MyTime = Time
msgbox myTime

Year
Dim MyDate, MyYear
MyDate = #October 19, 1962# ' Assign a date.
MyYear = Year(MyDate)
msgbox MyYear

Randomize 1
Dim MyValue, Response
Randomize ' Initialize random-number generator.
Do Until Response = vbNo
MyValue = Int((6 * Rnd) + 1) ' Generate random value between 1 and 6.
MsgBox MyValue
Response = MsgBox ("Roll again? ", vbYesNo)
Loop

Now
Dim MyVar
MyVar = Now ' MyVar contains the current date and time
msgbox Myvar

How to get the current date and time into a variable.
Dim fName
fName = fName & year(date)&month(date)&day(date)&"-"& hour(time)&minute(time)&second(time)
msgbox fname

How to kill excel sheets running in the background
set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'EXCEL.exe")
For Each objProcess in colProcess
objProcess.Terminate()
Next
Set objWMIService = Nothing
Set colProcess = Nothing

How to use the functions to convert the date into the DD/MM/YYYY format from YYYYMMDD 00:00:00
a = "20100906 03:34:56"
b=Split(a, " ")
YYYY=LEFT(b(0),4)
DD=RIGHT(b(0),2)
MM=RIGHT(LEFT(b(0),6),2)
finaldate= DD & "/" & MM &"/" & YYYY
msgbox finaldate

How to write into an Existing Excel Sheet using VB Script
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\GauravTest1.xlsx")
'objExcel.Application.Visible = True
objExcel.Workbooks.Add
objExcel.Cells(1, 1).Value = "Gaurav Seth55"
objExcel.ActiveWorkbook.Save "C:\GauravTest1.xlsx"
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit



Instr.VBS ( To Check if particular text contains a particular word or not)

var="raju want to marry"
If instr(1,var,"want") Then
msgbox "Exist"
else
msgbox "doesnot Exist"
End If



To Take the Screenshots and then paste them in the word document
‘ Note that Filename of word has to exist at the specified path and you need to specifiy the name of the image


Dim sReportPath, sImagePath
sReportPath = "C:\QTP\ReportFiles\Filename1.doc"
sImagePath = "C:\QTP\ScreenShots\baby12.png"

Desktop.CaptureBitmap sImagePath, true
Set oWord = CreateObject("Word.Application")
oWord.DisplayAlerts = False
oWord.Visible = False
oWord.documents.open sReportPath

For i=1 to 3

Set oDoc = oWord.ActiveDocument
Set oRange = oDoc.content
oRange.ParagraphFormat.Alignment = 0
oRange.insertafter vbcrlf
oRange.collapse(0)
oRange.InlineShapes.AddPicture sImagePath, False, True
oWord.ActiveDocument.Save
Next

oWord.Application.Quit True
Set oRange = Nothing
Set oDoc = Nothing
Set oWord = Nothing


' FormatDate time function formats and returns the valid date or time expression

msgbox formatdatetime(Now, VBGeneralDate)
msgbox formatdatetime(Now, VBLongDate)
msgbox formatdatetime(Now,VBShortDate)
msgbox formatdatetime(Now, VBLongDate)
msgbox formatdatetime(Now, VBshorttime)

'Msgbox and its return types
a= "String"
msgbox a, VBOKonly
msgbox a, vbOKCancel
msgbox a,vbAbortRetryIgnore
msgbox a, vbYesNoCancel
msgbox a, vbYesNo
msgbox a, vbRetryCancel
msgbox a, VbCritical
msgbox a, vbQuestion
msgbox a, vbExclamation
msgbox a,VbInformation
msgbox a,vbDefaultButton1
msgbox a, vbDefaultButton2
msgbox a,vbDefaultButton4
msgbox a,vbApplicationModal
msgbox a,vbSystemModal

Response=msgbox(vbOK) '1
Response=msgbox (vbCancel) '2
Response=msgbox (VBAbort) '3
Response=msgbox(vbRetry) '4
Response=msgbox(VBIgnore) '5
Response=msgbox(VBYES) '6
Response=msgbox(VBNO) '7
Resposne=msgbox(VBOKCancel)


'VB Script Error Handling
On Error Resume Next
Err.Raise 23 ' Raise an overflow error.
MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description)
Err.Clear ' Clear the error.

'1 TO 4-,8,12,15 Unknown Run time error
''5- Invalid Procedure Call or Argument
'7 -out of memory
'9-Subscript out of Range
'10 -Array is fixed or temporarily locked
'11 -Division by Zero
'13-Type mismatch
'14- Out of String Space
'17 -Cant perform requested operation

' Using the Replace function of the Regular Expressions to Replace a word in the String
Function ReplaceTest(patrn, replStr)
Dim regEx, str1 ' Create variables.
str1 = "The quick brown fox jumped over the lazy dog."
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Make case insensitive.
ReplaceTest = regEx.Replace(str1, replStr) ' Make replacement.
End Function
MsgBox(ReplaceTest("fox", "cat")) ' Replace 'fox' with 'cat'.

' Creating the Text Files and writing lines to it
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("c:\baby.txt", True)
' Write a line with a newline character.
tf.WriteLine("Testing 1, 2, 3.")
' Write three newline characters to the file.
tf.WriteBlankLines(3)
' Write a line.
tf.Write ("This is a test.")
tf.Close

Description.Create Object. The will give the number of browsers that are opened and will give title of them

Dim oDesc 'Description Object
Dim colObject 'Object Collection

Set oDesc = Description.Create
'Remember to always use 'micclass' and not 'class name'
oDesc( "micclass" ).value = "Browser"

'We used Desktop as the parent here because, the Desktop Object holds all the Windows
Set colObject = Desktop.ChildObjects( oDesc )

'Retrieve # of open browsers
MsgBox colObject.Count

'Retrieve Titles of all open browsers
For x = 0 to colObject.Count - 1
MsgBox colObject(x).GetROProperty("title")
Next

Framework Types

Data-Driven Testing

A data-driven framework is where test input and output values are read from data files (ODBC sources, CVS files, Excel files, DAO objects, ADO objects, and such) and are loaded into variables in captured or manually coded scripts.

Data driven means that we run same QTP script using different data.

For example you can create Login script and then use data driven methods to
run that script multiple times with multiple sets of userid and passwords.

1- Using QTP datatables
2- Using Excel sheets
3- Using Access database


You can use ADODB object to get data from Excel and Access and put that data in Arrays or Dictionary object and then can use that data in different scripts.

In this framework, variables are used for both input values and output verification values. Navigation through the program, reading of the data files, and logging of test status and information are all coded in the test script. This is similar to table-driven testing (which is discussed shortly) in that the test case is contained in the data file and not in the script; the script is just a "driver," or delivery mechanism, for the data. In data-driven testing, only test data is contained in the data files.

Merits of data-driven testing

1. Scripts may be developed while application development is still in progress

2. Utilizing a modular design, and using files or records to both input and verify data, reduces redundancy and duplication of effort in creating automated test scripts
If functionality changes, only the specific "Business Function" script needs to be updated

3. Data input/output and expected results are stored as easily maintainable text records.

Functions return "TRUE" or "FALSE" values to the calling script, rather than aborting, allowing for more effective error handling, and increasing the robustness of the test scripts. This, along with a well-designed "recovery" routine, enables "unattended" execution of test scripts.

Demerits of data-driven testing

1. Requires proficiency in the Scripting language used by the tool (technical personnel)
2. Multiple data-files are required for each Test Case. There may be any number of data-inputs and verifications required, depending on how many different screens are accessed. This usually requires data-files to be kept in separate directories by Test Case

Tester must not only maintain the Detail Test Plan with specific data, but must also re-enter this data in the various required data-files
If a simple "text editor" such as Notepad is used to create and maintain the data-files, careful attention must be paid to the format required by the scripts/functions that process the files, or script-processing errors will occur due to data-file format and/or content being incorrect

Keyword-Driven Testing

This requires the development of data tables and keywords, independent of the test automation tool used to execute them and the test script code that "drives" the application-under-test and the data. Keyword-driven tests look very similar to manual test cases. In a keyword-driven test, the functionality of the application-under-test is documented in a table as well as in step-by-step instructions for each test. In this method, the entire process is data-driven, including functionality.

Example
In order to open a window, the following table is devised, and it can be used for any other application, just it requires just changing the window name.

Test Table for Opening a Window
Window
Control
Action
Arguments
Window Name
Menu
Click
File, Open
Window Name
Menu
Click
Close
Window Name
Pushbutton
Click
Folder Name
Window Name
Verify
Results


Once creating the test tables, a driver script or a set of scripts is written that reads in each step executes the step based on the keyword contained the Action field, performs error checking, and logs any relevant information.

Merits of keyword driven testing

The Detail Test Plan can be written in Spreadsheet format containing all input and verification data.

If "utility" scripts can be created by someone proficient in the automated tool’s Scripting language prior to the Detail Test Plan being written, then the tester can use the Automated Test Tool immediately via the "spreadsheet-input" method, without needing to learn the Scripting language.

The tester need only learn the "Key Words" required, and the specific format to use within the Test Plan. This allows the tester to be productive with the test tool very quickly, and allows more extensive training in the test tool to be scheduled at a more convenient time.

Demerits of keyword driven testing

The demerits of the Keyword Driven Testing are as follows

Development of "customized" (Application-Specific) Functions and Utilities requires proficiency in the tool’s Scripting language. (Note that this is also true for any method)

If application requires more than a few "customized" Utilities, this will require the tester to learn a number of "Key Words" and special formats. This can be time-consuming, and may have an initial impact on Test Plan Development. Once the testers get used to this, however, the time required to produce a test case is greatly improved.

Hybrid Test Automation Framework

The most commonly implemented framework is a combination of all of the above techniques, pulling from their strengths and trying to mitigate their weaknesses. This hybrid test automation framework is what most frameworks evolve into over time and multiple projects. The most successful automation frameworks generally accommodate both Keyword-Driven testing as well as Data-Driven scripts.
This allows data driven scripts to take advantage of the powerful libraries and utilities that usually accompany a keyword driven architecture. The framework utilities can make the data driven scripts more compact and less prone to failure than they otherwise would have been.

The utilities can also facilitate the gradual and manageable conversion of existing scripts to keyword driven equivalents when and where that appears desirable. On the other hand, the framework can use scripts to perform some tasks that might be too difficult to re-implement in a pure keyword driven approach, or where the keyword driven capabilities are not yet in place. The following sections describe its architecture, merits and demerits.

Our test automation framework is a Hybrid Test Automation Framework

HP QTP - FAQ

What is QTP ?
A) QuickTest is a graphical interface record-playback automation tool. It is able to work with any web, java or windows client application. Quick Test enables you to test standard web objects and ActiveX controls. In addition to these environments, QuickTest Professional also enables you to test Java applets and applications and multimedia objects on Applications as well as standard Windows applications, Visual Basic 6 applications and .NET framework applications…



What are The Advantages and Disadvantages of Software Test Automation

Advantages of Test Automation

Fast

As manual testing consumes a great deal of time in both the process of software development as well as during the software application testing, automated tools are a faster option as long as the scripts which need to be done are standard and non complex.

Reliability

Automation of test script execution eliminates the possibility of human error when the same sequence of actions is repeated again and again. Remember this can be really important as you would be astonished to learn just how many test defects raised are in fact caused by tester error. This particularly happens when the same boring test scripts have to be run over and over again as well as when, at the opposite spectrum, really complex testing has to be done.

Comprehensive

Automated testers might contain a suite of tests that would help in testing each and every feature in the application. This means that chance of missing out key parts of testing is unlikely to occur. You might think this is unlikely to happen in reality, but I have managed a project where in fact a key part of functionality was overlooked by the test team.

Reusability

The test cases can be used in various versions of the software. Not only will your project management stakeholders be very grateful for the reduced project time and cost, but it will certainly help you when estimating project costs.

Programmable

One can program the test automation software to pull out elements of the software developed which otherwise may not have been uncovered. Hence this should make your testing even more thorough, something you may not be so keen on when defect after defect is raised as a result!

Disadvantages of Test Automation

It’s Not Easy!

Writing test automation scripts is not an easy task. You really need testers who are experienced in doing this otherwise it will go horribly wrong and you will end up spending even more money and time than if done manually. So bear this in mind when you are doing your project management resource allocation that you get the right testers on your project.

Automation Script Errors

If an error is made in the test automation scripts which is undetected, it could be fatal for the project since the correct testing won’t have been done. In fact you may not even realize the error until the software launches and then falls over.

Scope Changes

Every project will have to implement change request management. However despite best endeavours there will still be some which get through. The problem with this is that it may require the test automation scripts to be reprogrammed or redesigned. This may be the case even when there is a minor change in the user interface of the software.

Complexity

With the increase in the number of requirements (business requirements documentation and software requirements specification) that are to be tested, this leads to more and more complexity which makes the maintenance of test data extremely difficult.

Explain QTP Testing process ?
A) Create your test plan - Prior to automating there should be a detailed description of the test including the exact steps to follow, data to be input, and all items to be verified by the test. The verification information should include both data validations and existence or state verifications of objects in the application.

Recording a session on your application - As you navigate through your application, Quick Test graphically displays each step you perform in the form of a collapsible icon-based test tree. A step is any user action that causes or makes a change in your site, such as clicking a link or image, or entering data in a form.

Enhancing your test - Inserting checkpoints into your test lets you search for a specific value of a page, object or text string, which helps you identify whether or not your application is functioning correctly. NOTE: Checkpoints can be added to a test as you record it or after the fact via the Active Screen. It is much easier and faster to add the checkpoints during the recording process. Broadening the scope of your test by replacing fixed values with parameters lets you check how your application performs the same operations with multiple sets of data. Adding logic and conditional statements to your test enables you to add sophisticated checks to your test.

Debugging your test - If changes were made to the script, you need to debug it to check that it operates smoothly and without interruption.

Running your test on a new version of your application - You run a test to check the behavior of your application. While running, Quick Test connects to your application and performs each step in your test.


Analyzing the test results
- You examine the test results to pinpoint defects in your application.

Reporting defects - As you encounter failures in the application when analyzing test results, you will create defect reports in Defect Reporting Tool.

How Does Run time data (Parameterization) is handled in QTP?
A) You can then enter test data into the Data Table, an integrated spreadsheet with the full functionality of Excel, to manipulate data sets and create multiple test iterations, without programming, to expand test case coverage. Data can be typed in or imported from databases, spreadsheets, or text files.

What is keyword view and Expert view in QTP?
A) QuickTest’s Keyword Driven approach, test automation experts have full access to the underlying test and object propertyes, via an integrated scripting and debugging environment that is round-trip synchronized with the Keyword View.Advanced testers can view and edit their tests in the Expert View, which reveals the underlying industry-standard VBScript that QuickTest Professional automatically generates. Any changes made in the Expert View are automatically synchronized with the Keyword View.

Explain about the Test Fusion Report of QTP ?
A) Once a tester has run a test, a TestFusion report displays all aspects of the test run: a high-level results overview, an expandable Tree View of the test specifying exactly where application failures occurred, the test data used, application screen shots for every step that highlight any discrepancies, and detailed explanations of each checkpoint pass and failure. By combining TestFusion reports with QuickTest Professional, you can share reports across an entire QA and development team.

To which environments does QTP supports ?
A) QuickTest Professional supports functional testing of all enterprise environments, including Windows, Web, ..NET, Java/J2EE, SAP, Siebel, Oracle, PeopleSoft, Visual Basic, ActiveX, mainframe terminal emulators, and Web services.


Benefits of Test Automation Framework Approach:

Test Automation Framework built with systematic approach yields following benefits:

# Ensures consistency
# Significant reduction in the amount of code to develop & maintain thereby reducing the testing cycle time.
# Comprehensive coverage against requirements.
# Use of a "Common Standard" across the organization / Product team / Project team
# Maximizes reusability of test scripts ( Utility Functions)
# Provides a structured for test library having systematic maintenance of automation scripts
# Data Pooling
# Protects non-technical testers from the code

What are various types of properties when using object identification in QTP?

QTP uses three types of properties when identifying a object
1. Mandatory Properties - Always learn these properties for the object

2. Assistive Properties - Learn in case Mandatory properties are not enough to identify the object uniquely

3. Ordinal identifiers - Learn in case both mandatory and assistive properties are not able to recognize the objects correctly

How QTP recognizes Objects in AUT?
A) QuickTest stores the definitions for application objects in a file called the Object Repository. As you record your test, QuickTest will add an entry for each item you interact with. Each Object Repository entry will be identified by a logical name (determined automatically by QuickTest), and will contain a set of properties (type, name, etc) that uniquely identify each object. Each line in the QuickTest script will contain a reference to the object that you interacted with, a call to the appropriate method (set, click, check) and any parameters for that method (such as the value for a call to the set method). The references to objects in the script will all be identified by the logical name, rather than any physical, descriptive properties.

What are the types of Object Repositorys in QTP?
A) QuickTest has two types of object repositories for storing object information: shared object repositories and action object repositories. You can choose which type of object repository you want to use as the default type for new tests, and you can change the default as necessary for each new test. The object repository per-action mode is the default setting. In this mode, QuickTest automatically creates an object repository file for each action in your test so that you can create and run tests without creating, choosing, or modifying object repository files. However, if you do modify values in an action object repository, your changes do not have any effect on other actions. Therefore, if the same test object exists in more than one action and you modify an object’s property values in one action, you may need to make the same change in every action (and any test) containing the object.

Explain the check points in QTP?
A) . A checkpoint verifies that expected information is displayed in a Application while the test is running. You can add eight types of checkpoints to your test for standard web objects using QTP.
A page checkpoint checks the characteristics of a Application
A text checkpoint checks that a text string is displayed in the appropriate place on a Application.
An object checkpoint (Standard) checks the values of an object on a Application.
An image checkpoint checks the values of an image on a Application.
A table checkpoint checks information within a table on a Application
An Accessiblity checkpoint checks the web page for Section 508 compliance.
An XML checkpoint checks the contents of individual XML data files or XML documents that are part of your Web application.
A database checkpoint checks the contents of databases accessed by your web site




In how many ways we can add check points to an application using QTP.
A)We can add checkpoints while recording the application or we can add after recording is completed using Active screen (Note : To perform the second one The Active screen must be enabled while recording).

How does QTP identifes the object in the application
A)QTP identifies the object in the application by LogicalName and Class. For example : The Edit box is identified by Logical Name : PSOPTIONS_BSE_TIME20Class: WebEdit

If an application name is changes frequently i.e while recording it has name “Window1” and then while running its “Windows2” in this case how does QTP handles?
A) QTP handles those situations using “Regular Expressions”.

What is Parameterizing Tests?
A) When you test your application, you may want to check how it performs the same operations with multiple sets of data. For example, suppose you want to check how your application responds to ten separate sets of data. You could record ten separate tests, each with its own set of data. Alternatively, you can create a parameterized test that runs ten times: each time the test runs, it uses a different set of data.

What is test object model in QTP ?
A) The test object model is a large set of object types or classes that QuickTest uses to represent the objects in your application. Each test object class has a list of properties that can uniquely identify objects of that class and a set ofrelevant methods that QuickTest can record for it.A test object is an object that QuickTest creates in the test or component to represent the actual object in your application. QuickTest stores information about the object that will help it identify and check the object during the run session.A run-time object is the actual object in your Web site or application onwhich methods are performed during the run session.When you perform an operation on your application while recording,QuickTest:➤ identifies the QuickTest test object class that represents the object on whichyou performed the operation and creates the appropriate test object➤ reads the current value of the object’s properties in your application andstores the list of properties and values with the test object➤ chooses a unique name for the object, generally using the value of one of itsprominent properties➤ records the operation that you performed on the object using the appropriate QuickTest test object methodFor example, suppose you click on a Find button with the following HTMLsource code:QuickTest identifies the object that you clicked as a WebButton test object.It creates a WebButton object with the name Find, and records the followingproperties and values for the Find WebButton:It also records that you performed a Click method on the WebButton.QuickTest displays your step in the Keyword View like this:QuickTest displays your step in the Expert View like this:Browser(“Mercury Interactive”).Page(“Mercury Interactive”).WebButton(“Find”).Click

What is Object Spy in QTP?
A) Using the Object Spy, you can view the properties of any object in an openapplication. You use the Object Spy pointer to point to an object. The ObjectSpy displays the selected object’s hierarchy tree and its properties and valuesin the Properties tab of the Object Spy dialog box.

What is the Diff between Image check-point and Bit map Check point?
A) Image checkpoints enable you to check the properties of a Web image. You can check an area of a Web page or application as a bitmap. While creating a test or component, you specify the area you want to check by selecting an object. You can check an entire object or any area within an object. QuickTest captures the specified object as a bitmap, and inserts a checkpoint in the test or component. You can also choose to save only the selected area of the object with your test or component in order to save disk Space For example, suppose you have a Web site that can display a map of a city the user specifies. The map has control keys for zooming. You can record the new map that is displayed after one click on the control key that zooms inthe map. Using the bitmap checkpoint, you can check that the map zooms in correctly.You can create bitmap checkpoints for all supported testing environments(as long as the appropriate add-ins are loaded).Note: The results of bitmap checkpoints may be affected by factors such asoperating system, screen resolution, and color settings.

How many ways we can parameterize data in QTP ?
A) There are four types of parameters:Test, action or component parameters enable you to use values passedfrom your test or component, or values from other actions in your test. Data Table parameters enable you to create a data-driven test (or action)that runs several times using the data you supply. In each repetition, oriteration, QuickTest uses a different value from the Data Table. Environment variable parameters enable you to use variable values fromother sources during the run session. These may be values you supply, orvalues that QuickTest generates for you based on conditions and optionsyou choose. Random number parameters enable you to insert random numbers asvalues in your test or component. For example, to check how yourapplication handles small and large ticket orders, you can have QuickTestgenerate a random number and insert it in a number of tickets edit field.

How do u do batch testing in WR & is it possible to do in QTP, if so explain?
Ans: Batch Testing in WR is nothing but running the whole test set by selecting “Run Testset” from the “Execution Grid”.The same is possible with QTP also. If our test cases are automated then by selecting “Run Testset” all the test scripts can be executed. In this process the Scripts get executed one by one by keeping all the remaining scripts in “Waiting” mode.

If i give some thousand tests to execute in 2 days what do u do?
Ans : Adhoc testing is done. It Covers the least basic functionalities to verify that the system is working fine.

What does it mean when a check point is in red color? what do u do?
Ans : A red color indicates failure. Here we analyze the the cause for failure whether it is a Script Issue or Envronment Issue or a Application issue.

How do u do batch testing in WR & is it possible to do in QTP, if so explain?
Ans : You can use Test Batch Runner to run several tests in succession. The results for each test are stored in their default location. Using Test Batch Runner, you can set up a list of tests and save the list as an .mtb file, so that you can easily run the same batch of tests again, at another time. You can also choose to include or exclude a test in your batch list from running during a batch run


What does it mean when a check point is in red color? what do u do?
Ans : A red color indicates failure. Here we analyze the the cause for failure whether it is a Script Issue or Envronment Issue or a Application issue.


How to Import data from a “.xls” file to Data table during Runtime.
Ans : Datatable.Import “…XLS file name…” DataTable.ImportSheet(FileName, SheetSource, SheetDest) DataTable.ImportSheet “C:\name.xls” ,1 ,”name”

How to export data present in Datatable to an “.xls” file?
Ans : DataTable.Export “….xls file name…”


3 differences between QTP & Winrunner?
Ans :
(a) QTP is object bases Scripting ( VBS) where Winrunner is TSL (C based) Scripting. (b) QTP supports “.NET” application Automation not available in Winrunner (c) QTP has “Active Screen” support which captures the application, not available in WR.
(d) QTP has “Data Table” to store script values , variables which WR does not have. (e) Using a “point and click” capability you can easily interface with objects, their definitions and create checkpoints after having recorded a script – without having to navigate back to that location in your application like you have to with WinRunner. This greatly speeds up script development.

How to create a Runtime property for an object?
How to add a runtime parameter to a datasheet?
Ans: DataTable.LocalSheet
The following example uses the LocalSheet property to return the local sheet of the run-time Data Table in order to add a parameter (column) to it. MyParam=DataTable.LocalSheet.AddParameter(“Time”, “5:45″)


Analyzing the Checpoint results
A)Standard Checpoint :By adding standard checkpoints to your tests or components, you can compare the expected values of object properties to the object’s current values during a run session. If the results do not match, the checkpoint fails.

Table and DB Checkpoints:
By adding table checkpoints to your tests or components, you can check that a specified value is displayed in a cell in a table on your application. By adding database checkpoints to your tests or components, you can check the contents of databases accessed by your application. The results displayed for table and database checkpoints are similar. When you run your test or component, QuickTest compares the expected results of the checkpoint to the actual results of the run session. If the results do not match, the checkpoint fails. You can check that a specified value is displayed in a cell in a table by adding a table checkpoint to your test or component. For ActiveX tables, you can also check the properties of the table object. To add a table checkpoint, you use the Checkpoint Properties dialog box. Table checkpoints are supported for Web and ActiveX applications, as well as for a variety of external add-in environments. You can use database checkpoints in your test or component to check databases accessed by your Web site or application and to detect defects. You define a query on your database, and then you create a database checkpoint that checks the results of the query. Database checkpoints are supported for all environments supported by QuickTest, by default, as well as for a variety of external add-in environments. There are two ways to define a database query: (a) Use Microsoft Query. You can install Microsoft Query from the custom installation of Microsoft Office. (b) Manually define an SQL statement. The Checkpoint timeout option is available only when creating a table checkpoint. It is not available when creating a database checkpoint

Checking Bitmaps:
You can check an area of a Web page or application as a bitmap. While creating a test or component, you specify the area you want to check by selecting an object. You can check an entire object or any area within an object. QuickTest captures the specified object as a bitmap, and inserts a checkpoint in the test or component. You can also choose to save only the selected area of the object with your test or component in order to save disk space. When you run the test or component, QuickTest compares the object or selected area of the object currently displayed on the Web page or application with the bitmap stored when the test or component was recorded. If there are differences, QuickTest captures a bitmap of the actual object and displays it with the expected bitmap in the details portion of the Test Results window. By comparing the two bitmaps (expected and actual), you can identify the nature of the discrepancy. For more information on test results of a checkpoint, see Viewing Checkpoint Results. For example, suppose you have a Web site that can display a map of a city the user specifies. The map has control keys for zooming. You can record the new map that is displayed after one click on the control key that zooms in the map. Using the bitmap checkpoint, you can check that the map zooms in correctly. You can create bitmap checkpoints for all supported testing environments (as long as the appropriate add-ins are loaded). Note: The results of bitmap checkpoints may be affected by factors such as operating system, screen resolution, and color settings.

Text/Text Area Checkpoint :
In the Text/Text Area Checkpoint Properties dialog box, you can specify the text to be checked as well as which text is displayed before and after the checked text. These configuration options are particularly helpful when the text string you want to check appears several times or when it could change in a predictable way during run sessions. Note: In Windows-based environments, if there is more than one line of text selected, the Checkpoint Summary pane displays [complex value] instead of the selected text string. You can then click Configure to view and manipulate the actual selected text for the checkpoint. QuickTest automatically displays the Checked Text in red and the text before and after the Checked Text in blue. For text area checkpoints, only the text string captured from the defined area is displayed (Text Before and Text After are not displayed). To designate parts of the captured string as Checked Text and other parts as Text Before and Text After, click the Configure button. The Configure Text Selection dialog box opens Checking XML : XML (Extensible Markup Language) is a meta-markup language for text documents that is endorsed as a standard by the W3C. XML makes the complex data structures portable between different computer environments/operating systems and programming languages, facilitating the sharing of data. XML files contain text with simple tags that describe the data within an XML document. These tags describe the data content, but not the presentation of the data. Applications that display an XML document or file use either Cascading Style Sheets (CSS) or XSL Formatting Objects (XSL-FO) to present the data. You can verify the data content of XML files by inserting XML checkpoints. A few common uses of XML checkpoints are described below: An XML file can be a static data file that is accessed in order to retrieve commonly used data for which a quick response time is needed—for example, country names, zip codes, or area codes. Although this data can change over time, it is normally quite static. You can use an XML file checkpoint to validate that the data has not changed from one application release to another. An XML file can consist of elements with attributes and values (character data). There is a parent and child relationship between the elements, and elements can have attributes associated with them. If any part of this structure (including data) changes, your application’s ability to process the XML file may be affected. Using an XML checkpoint, you can check the content of an element to make sure that its tags, attributes, and values have not changed. XML files are often an intermediary that retrieves dynamically changing data from one system. The data is then accessed by another system using Document Type Definitions (DTD), enabling the accessing system to read and display the information in the file. You can use an XML checkpoint and parameterize the captured data values in order to check an XML document or file whose data changes in a predictable way. XML documents and files often need a well-defined structure in order to be portable across platforms and development systems. One way to accomplish this is by developing an XML schema, which describes the structure of the XML elements and data types. You can use schema validation to check that each item of content in an XML file adheres to the schema description of the element in which the content is to be placed.

Object Repositories types, Which & when to use? Deciding Which Object Repository Mode to Choose

A)To choose the default object repository mode and the appropriate object repository mode for each test, you need to understand the differences between the two modes. In general, the object repository per-action mode is easiest to use when you are creating simple record and run tests, especially under the following conditions: You have only one, or very few, tests that correspond to a given application, interface, or set of objects. You do not expect to frequently modify test object properties. You generally create single-action tests. Conversely, the shared object repository mode is generally the preferred mode when: You have several tests that test elements of the same application, interface, or set of objects. You expect the object properties in your application to change from time to time and/or you regularly need to update or modify test object properties. You often work with multi-action tests and regularly use the Insert Copy of Action and Insert Call to Action options.

Can we Script any test case with out having Object repository? or Using Object Repository is a must?
Ans: No. U can script with out Object repository by knowing the Window Handlers, spying and recognizing the objects logical names and properties available.

How to execute a WinRunner Script in QTP?
Ans : (a) TSLTest.RunTest TestPath, TestSet [, Parameters ] –> Used in QTP 6.0 used for backward compatibility Parameters :
The test set within Quality Center, in which test runs are stored. Note that this argument is relevant only when working with a test in a Quality Center project. When the test is not saved in Quality Center, this parameter is ignored. e.g : TSLTest.RunTest “D:\test1″, “” (b) TSLTest.RunTestEx TestPath, RunMinimized, CloseApp [, Parameters ] TSLTest.RunTestEx “C:\WinRunner\Tests\basic_flight”, TRUE, FALSE, “MyValue” CloseApp : Indicates whether to close the WinRunner application when the WinRunner test run ends. Parameters : Up to 15 WinRunner function argument

How to handle Run-time errors?
(a) On Error Resume Next : causes execution to continue with the statement immediately following the statement that caused the run-time error, or with the statement immediately following the most recent call out of the procedure containing the On Error Resume Next statement. This allows execution to continue despite a run-time error. You can then build the error-handling routine inline within the procedure. Using “Err” object msgbox “Error no: ” & “ ” & Err.Number & “ ” & Err.description & “ ” & Err.Source & Err.HelpContext

How to change the run-time value of a property for an object?
Ans : SetTOProperty changes the property values used to identify an object during the test run. Only properties that are included in the test object description can be set

How to retrieve the property of an object?
Ans : using “GetRoProperty”.

How to open any application during Scripting?
Ans : SystemUtil , object used to open and close applications and processes during a run session.
(a) A SystemUtil.Run statement is automatically added to your test when you run an application from the Start menu or the Run dialog box while recording a test E.g : SystemUtil.Run
“Notepad.exe” SystemUtil.CloseDescendentProcesses ( Closes all the processes opened by QTP )

Types of properties that Quick Test learns while recording?
Ans : (a) Mandatory (b) Assistive . In addition to recording the mandatory and assistive properties specified in the Object Identification dialog box, QuickTest can also record a backup ordinal identifier for each test object. The ordinal identifier assigns the object a numerical value that indicates its order relative to other objects with an otherwise identical description (objects that have the same values for all properties specified in the mandatory and assistive property lists). This ordered value enables QuickTest to create a unique description when the mandatory and assistive properties are not sufficient to do so.

What is the extension of script and object repository files?
Ans : Object Repository : .tsr , Script : .mts, Excel : Default.xls

How to supress warnings from the “Test results page”?
Ans : From the Test results Viewer “Tools > Filters > Warnings”…must be “Unchecked”.

When we try to use test run option “Run from Step”, the browser is not launching automatically why?
Ans : This is default behaviour.

Does QTP is “Unicode” compatible?
Ans : QTP 6.5 is not but QTP 8.0 is expected to be Unicode compatabile by end of December 2004.

How to “Turn Off” QTP results after running a Script?
Ans : Goto “Tools > Options > Run Tab” and Deselect “View results when run session ends”. But this supresses only the result window, but a og will be created and can viewed manulaly which cannot be restricted from getting created.


How to verify the Cursor focus of a certain field?
Ans : Use “focus” property of “GetRoProperty” method” 6
1. Any limitation to XML Checkpoints? Ans : Mercury has determined that 1.4MB is the maximum size of a XML file that QTP 6.5 can handle

How to make arguments optional in a function?
Ans : this is not possible as default VBS doesn’t support this. Instead you can pass a blank scring and have a default value if arguments r not required.

How to covert a String to an integer?
Ans : CInt()—> a conversion function available.

Inserting a Call to Action is not Importing all columns in Datatable of globalsheet. Why?
Ans : Inserting a call to action will only Import the columns of the Action called

How to add a constant number in a datatable?
A)This is more to do with MS excel then QTP!! but useful to know because at times it becomes frustrating to the novices.ust append ' to the number
Ex: if you wish to enter 1234567 in datatable then write it as '1234567

How can i check if a parameter exists in DataTable or not?
A)The best way would be to use the below code:
on error resume next
val=DataTable("ParamName",dtGlobalSheet)
if err.number<> 0 then
'Parameter does not exist
else
'Parameter exists
end if

How can i check if a checkpoint passes or not?
A) chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))
if chk_PassFail then
MsgBox "Check Point passed"
else MsgBox "Check Point failed"
end if

My test fails due to checkpoint failing, Can i validate a checkpoint without my test failing due to checpoint failure?
A) Reporter.Filter = rfDisableAll 'Disables all the reporting stuff
chk_PassFail = Browser(...).Page(...).WebEdit(...).Check (Checkpoint("Check1"))
Reporter.Filter = rfEnableAll 'Enable all the reporting stuff
if chk_PassFail then
MsgBox "Check Point passed"
else
MsgBox "Check Point failed"
end if

What is the difference between an Action and a function?

A)Action is a thing specific to QTP while functions are a generic thing which is a feature of VB Scripting. Action can have a object repository associated with it while a function can't. A function is just lines of code with some/none parameters and a single return value while an action can have more than one output parameters.

Where to use function or action?
A) Well answer depends on the scenario. If you want to use the OR feature then you have to go for Action only. If the functionality is not about any automation script i.e. a function like getting a string between to specific characters, now this is something not specific to QTP and can be done on pure VB Script, so this should be done in a function and not an action. Code specific to QTP can also be put into an function using DP. Decision of using function/action depends on what any one would be comfortable using in a given situation.

When to use a Recovery Scenario and when to us on error resume next?
A) Recovery scenarios are used when you cannot predict at what step the error can occur or when you know that error won't occur in your QTP script but could occur in the world outside QTP, again the example would be "out of paper", as this error is caused by printer device driver. "On error resume next" should be used when you know if an error is expected and dont want to raise it, you may want to have different actions depending upon the error that occurred. Use err.number & err.description to get more details about the error.

How to use environment variable?
A) A simple defintion could be... it is a variable which can be used across the reusable actions and is not limited to one reusable action.
There are two types of environment variables:
1. User-defined
2. Built-in
We can retrieve the value of any environment variable. But we can set the value of only user-defined environment variables.

To set the value of a user-defined environment variable:
A)Environment (VariableName) = NewValue

To retrieve the value of a loaded environment variable:
A)CurrValue = Environment (VariableName)

Example
The following example creates a new internal user-defined variable named MyVariable with a value of 10, and then retrieves the variable value and stores it in the MyValue variable.

Environment.Value("MyVariable")=10
MyValue=Environment.Value("MyVariable")


What are the files and subfolders of a QuickTest Professional test?
A)The files and folders hold binary and text data that are required for the test to run successfully.
The following table provides a description, the type, and comments regarding the files that make up a QuickTest Professional test.

File Name Description Type Comments Regarding File
Test.tsp Test settings Binary Do not edit
Default.xls Data table parameters Excel similar Can be edited using Excel
Parameters.mtr Parameterization info Binary Do not edit
Action Action folder
Default.cfg Load test configuration file Text Do not edit
Default.prm Load test configuration file Text Do not edit
Default.usp Load test configuration file Text Do not edit
.usr Load test configuration file Text Do not edit
Thick_usr.dat Load test configuration file Text Do not edit
Thin_usr.dat Load test configuration file Text Do not edit

Files within Action folder:
File Name Description Type Comments Regarding File
Script.mts Action script Text Edit text preceding the @@
Resource.mtr Object Repository Binary Do not edit
Snapshots Active screen files Folder Do not edit

There are few more files extensions like
.MTB Batch File
.LCK Locked

How to rename a checkpoint (QTP 9.0)?
A) Example:
Window("Notepad").WinEditor("Edit").Check CheckPoint("Edit")
In the above example, the user would like to change the name of the CheckPoint object from "Edit" to something more meaningful.
Note:
This functionality is new to QuickTest Professional 9.0.This is not available for QTP 8.2 and below.
1. Right-click on the Checkpoint step in the Keyword View or on the Checkpoint object in Expert View.
2. Select "Checkpoint Properties" from the pop-up menu.
3. In the Name field, enter the new checkpoint name.
4. Click . The name of the checkpoint object will be updated within the script.
Example:
Window("Notepad").WinEditor("Edit").Check CheckPoint("NewCheckPointName")
Note:
You must use the QuickTest Professional user interface to change the name of the checkpoint. If you manually change the name of the checkpoint in the script, QuickTest Professional will generate an error during replay. The error message will be similar to the following:
"The "" CheckPoint object was not found in the Object Repository. Check the Object Repository to confirm that the object exists or to find the correct name for the object."
The CheckPoint object is not a visible object within the object repository, so if you manually modify the name, you may need to recreate the checkpoint to resolve the error.

Does QuickTest Professional support Internet Explorer 7.0?
A)
QuickTest Professional 9.1
QuickTest Professional 9.1 supports Microsoft Internet Explorer 7.0 Beta 3. Internet Explorer version 7.0 is now certified to work and to be tested with QuickTest Professional version 9.1.
QuickTest Professional 9.0
QuickTest Professional 9.0 supports Internet Explorer 7.0 Beta 2.
QuickTest Professional 8.2 and below
QuickTest Professional 8.2 and below do not include support for Internet Explorer 7.0.


Does QuickTest Professional support Firefox?
QuickTest Professional 9.1 and 9.2
QuickTest Professional 9.1 provides replay support for Mozilla Firefox 1.5 and Mozilla Firefox 2.0 Alpha 3 (Alpha-level support for Bon Echo 2.0a3).
Notes:
QuickTest Professional 9.1 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.
The .Object property for web objects is not supported in FireFox.
QuickTest Professional 9.0
QuickTest Professional 9.0 provides replay support for Mozilla FireFox 1.5.
Notes:
QuickTest Professional 9.0 will not record on FireFox. You can record a test on Microsoft Internet Explorer and run it on any other supported browser, such as FireFox.
The .Object property for web objects is not supported in FireFox.
QuickTest Professional 8.2 and below
QuickTest Professional 8.2 and below do not have support for Firefox.



What is the lservrc file in QTP?
A) The lservrc file contains the license codes that have been installed
The lservrc file contains the license codes that have been installed. Whenever a new license is created, the license code is automatically added to this file. The lservrc file is a text file, with no extension.
File Location:

1) For a Concurrent (Floating) license installation:
"#server installation directory#\#language#"
Example:
C:\Program Files\XYZ Technologies\ABC Server\English\lservrc
2) For a Seat (Stand-alone) license installation:
#AQT/QTP installation directory#\bin"
Example:
C:\Program Files\Mercury Interactive\QuickTest Professional\Bin\lservrc

What to do if you are not able to run QTP from quality center?
A)This is for especially for newbies with QTP.
Check that you have selected Allow other mercury products to run tests and components from Tools--> Options--> Run Tab.


A)Does QuickTest Professional support Macintosh operating systems?
No, QTP is not expected to run on this OS.


To terminate an application that is not responding we use:
A)SystemUtil.CloseProcessByName

The method that adds to the test while implementing synchronization is:
A)WaitProperty

The command used to invoke other application from QTP:
A)InvokeApplication, SystemUtil.Run

The method used for sending information to the test results is:
A)Reporter.reportevent()

The command used to retrieve data from excel sheet is
A) Set ab = CreateObject("srcfilepath ") , Set ws = ab.getsheet(sheetid)

The method used to open the specified URL in a browser is:
A)navigate()

The 3 Parameter types available in data driver is:
A)DataTable,Environment,Random number

The method added to the test while parameterizing is:
A)Set DataTable(variable, dtGlobalSheet)

The length of the array can be get by the method:
A)ubound(array)

The Command used to insert the transactions in test is:
A). Services.StartTransaction "Name", Services.EndTransaction "Name"

Explain what the difference between Shared Repository and Per Action Repository

A)Shared Repository: Entire application uses one Object Repository , that similar to Global GUI Map file in WinRunner Per Action: For each Action, one Object Repository is created, like GUI map file per test in WinRunner

What is the difference between check point and output value?
An output value is a value captured during the test run and entered in the run-time but to a specified location. EX:-Location in Data Table[Global sheet / local sheet]



What is Hybrid Framework and how it is useful?

The combination of both keyword and data driven framework is known as a hybrid framework. At the time of the building of the framework the objects which are not going to change should be taken and hard coded in the application and from the data sheet the frequently changing objects should be taken. If any framework consists of 2 or more frameworks then it is a hybrid framework.

For what purpose step generator is used?

Step generator is used to insert steps in a test by selecting from a range of context-sensitive options and by entering the required values. It breaks the test to achieve proper testing results. It thus saves time instead of recording a step can be generated for a particular step. The step generator can be used from both the keyboard view and the expert view.

In what situations QTP will not recognize the Objects?

1. If the AUT change
2. If AUT is in another window
3. If synchronization is a problem If QTP is running faster than the application.


In what situations QTP will not recognize the Objects?
TP 9.2 provides two options fo object identification Tool->Object Identification it provides a furthur option under it called smart Identification..u can configure it to recognize the objects which are not recognised by QTP normally!!

Give me an example where you have used a COM interface in your QTP project?
- com interface appears in the scenario of front end and back end. for eg:if you r using oracle as back end and front end as VB or any language then for better compatibility we will go for an interface. of which COM will be one among those interfaces. Create object creates handle to the instance of the specified object so that we program can use the methods on the specified object. It is used for implementing Automation(as defined by Microsoft).


How many types of recording facility are available in QuickTest Professional (QTP)?
QTP provides three types of recording methods-
* Context Recording (Normal)
* Analog Recording
* Low Level Recording

What are assistive properties or an ordinal identifier?
When mandatory property values are not sufficient to uniquely identify the object within its parent object, QuickTest adds some assistive properties and/or an ordinal identifier to create a unique description. Note: You can retrieve or modify property values of the test object during the run session by adding GetTOProperty and SetTOProperty statements in the Keyword View or Expert View. You can retrieve property values of the runtime object during the run session by adding GetROProperty statements. If the available test object methods or properties for an object do not provide the functionality you need, you can access the internal methods and properties of any run-time object using the Object property. You can also use the attribute object property to identify Web objects in your application according to user-defined properties.

Explain the terms Password Encoder, Remote Agent, Test Batch Runner, Test Results Deletion tool?

Password Encoder—enables you to encode passwords. You can use the resulting strings as method arguments or Data Table parameter values. Remote Agent—determines how QuickTest behaves when a test or component is run by a remote application such as Quality Center. Test Batch Runner—enables you to set up QuickTest to run several tests in succession. Test Results Deletion Tool—enables you to delete unwanted or obsolete results from your system according to specific criteria that you define.


How to connect to a database?
code:
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DRIVER={Microsoft ODBC for Oracle};UID=;PWD=
"
objRecordset.CursorLocation = adUseClient
objRecordset.CursorType = adopenstatic
objRecordset.LockType = adlockoptimistic
ObjRecordset.Source="select field1,field2 from testTable"
ObjRecordset.ActiveConnection=ObjConnection ObjRecordset.Open 'This will execute your Query
If ObjRecordset.recordcount>0 then
Field1 = ObjRecordset("Field1").Value
Field2 = ObjRecordset("Field2").Value
End if

What are the Run modes in QTP ?

There are 2 run modes in QTP
* Normal : It shows the execution of your QTP script step by step. This works good in case of debugging your script.
* Fast Run : It will not show the execution line by line.

What are the Debugging modes used in QTP ?

Different Debugging modes used in QTP are
* Step Into : To run only the current line of the active test or component.
* Step Out : Runs to the end of the called action or user-defined function, then returns to the calling action and pauses the run session.
* Step Over : to run only the current step in the active test or component. When the current step calls another action or a user-defined function,the called action or function is executed entirety, but the called action script is not displayed in the QuickTest window.

What are the draw backs of QTP ?

Disadvantages are
* QTP takes very long to open huge tests. Also CPU utilization becomes 100% in that case.
* QTP scripts are heavy as it stores all the html files (for active screen) as well.
* Block commenting is not provided till 8.2 version.

What are the extension of file..........

* Per test object repository : filename.mtr (Mercury Test Repository)
* Shared Oject repository : filename.tsr (Test Shared Repository)
* User Defined Libary File : filename .vbs
* Test Batch Runner File : filename .mtb
* QTP Recovery Scenarion File : filename .qrs

What are two types of automation in QTP ?

There are 2 types of automation

* Recording or generating the script and playing back using Repository
* Another one is Descriptive method.

Can we do more than capture / payback in QTP ?

Yes we can do. That is scripting we can write script which is more effective

What is Descriptive programming ?

With out mentioning the description in Object repository, we can directly mention the description in Test script is known as descriptive programming

What is Object repository ?

Object repository in qtp is like a storage place where it stores the properties of all the objects when we reocrd the script and later when we execute the script QTP checks that the objects in the application match the objects in the object repository and executes it, if both the objects matches the test will pass, if it cannot identify the object or there is a mismatch the script will fail.

Object repository is same as GUI map in winrunner where we have to make the tool capture the properties of object where as in QTP object repository automatically does that for us.

What are types of Object repository (OR)?

OR are of two types
* Per-action
* Shared

Tell about Per-action repository modes

In this, for each action a seperate object repository file is created. So object1 in Action1 is different from the same object1 in Action2
This mode is most useful, when the object does not change frequently and a few actions are associated with the test. If the object changes in the application, then we need to change each of the object repositor.

Tell about Shared object repository modes

In this, common object repository file can be used for muliple actions and multile tests. So Object1 is action1 is same for Action2, because all the objects are saved at one place. Here if the object changes, then we need to update a single object repository file.

What are the Advantage & Disadvantge Per-action repository ?

Advantage

* As you record operations on objects in your application, QuickTest automatically stores the information about those objects in the appropriate action object repository.
* When you save your test, all of the action object repositories are automatically saved with the test as part of each action within the test. The action object repository is not accessible as a separate file (as is the shared object repository).

Disadvantages

* Modifying the test object properties, values, or names in one object repository does not affect the information stored for the same test object in another object repository or in other tests - Time Consuming
* If you add objects to one of the split actions, the new objects are added only to the corresponding action object repository.

What are the Advantage & Disadvantge Shared object repository ?

Advantage

* Only one instance of the object in the repository so reduce the repetitions
* one time change to the object properties would bring change in every script using the object

Disadvantge

* Complexity increase as objects of all the action are in the same repository

What is Check points ?

A checkpoint verifies that expected information is displayed in an Application while the test is running. Checkpoints are used to compare actual and expected results.

How many Check points are there in QTP ?

They are 4 types of checkpoints

* GUI Check point
* Bitmap Checkpoint
* Database Checkpoint
* Test Checkpoint

What is the use of Check points ?

The Check points is useful to get the point in time from where to begin the recovery in case of failure.

Can we change the name of the Check points ?

No, QTP is do not allow to change the name of Check point, because these class names are internally built. But in version 9 (just released) it is possible to cahange not in previous versions

What is Transaction ?

A Transaction is a logical unit of work that comprises one or more SQL statements executed by a single user. or It is a group of statements between two commits

What is use of Step Generator ?

Step Generator is used to insert a statement(function ro method) of a particular object which is available in the Object Repository

What is Source Control ?

The practice of tracking changes made to code is called Source Control.
Familiar Source control Tools are CVS, VSS, ClearCase etc

What is Batch testing ?

Group of tests executing sequentially one by one is called Batch Testing. Every test Batch consists of mutiple dependent test cases. In those batches every end state is base state to next case. Test batch is also known as Test suit or Test belt.

Generally Test engineers are executing test programs as a batches because "End state of one test is base state to another test".
The result of one Script failure or pass , fails or passes the whole batch test.

What will you when Object is not indentifed by the Obect Repository ?

Use Smart identifcation.

What is Smart identifcation ?

Smart Identification is used by QTP, whenever it is unable to identify any object during run time. While identifying an object, QTP tries to match the mandatory properties first, if it couldn't find the object, then it adds assistive properties one by one to identify the object correctly. This operation is done by smart identifier and it is displayed in the results section along with one warning message. It's generally used to identify Web elements only.

What is Envoirement variable ?

Envoirement variable is variable which is global through the testing.

What is the typesof Envoirement variable ?

There are 3 types of environmental variables
* User-Defined Internal
* User-Defined External
* Built-In

What are Exception in QTP ?

The four exceptions are
* Pop exception
* Object state
* Test run error
* Application crash

Can We use Test Director with QTP ?

Yes. We cant use Test Director 7.2 with QTP 8.2. Because QTP 8.2 supports QC (Quality Center)
We can use QTP 8.2 with Test director 8.0.

What are Action ?

There are 3 types of Actions available in QTP.
* Non-reusable
* Reusable
* External Actions

What is Framework ?

A framework is nothing but a folder structure . It contains all the components that are using in Automation Architecture. Here components means Object Repository, Library,Logs, Test Data, Script, Result etc

What is Compiled modules ?

In qtp the compiled modules are called library files .

What is Automation Framework ?

Automation frame work is nothing but a set of rules defined for developping and organising the test scripts or
It is a process to develop the automation scripts and reduce maintenance. This framework completely depends on the application, types of testing and tools that you are using. Its hard to provide generalised framework for all applications:

In how many ways we can Parameterize our test ?

we can parameterize our tests in 4 ways.
* Test or component parameter
* Data Table parameter
* Environmental variable parameter
* Random number parameter

What are tyes of Table ?

Types of tables are
* run time data table
* design time data table


What is Index Property for identifying the objects in QTP?
While learning an object, QTP can assign a value to the test object’s Index property to uniquely identify the object. The value is based on the order in which the object appears within the source code. The first occurrence is 0.

Index property values are object-specific. Therefore, if you use Index:=3 to describe a WebEdit test object, QTP searches for the fourth WebEdit object in the page.

However, if you use Index:=3 to describe a WebElement object, QTPt searches for the fourth Web object on the page—regardless of the type—because the WebElement object applies to all Web objects.

What are the situations best suited to Recording in QTP?

Recording can be useful in the following situations:

# Recording helps novice QuickTest users learn how QTP interprets the operations you perform on your application, and how it converts them to QTP objects and built-in operations.

# Recording can be useful for more advanced QTP users when working with a new application or major new features of an existing application (for the same reasons described above). Recording is also helpful while developing functions that incorporate built-in QTP keywords.

# Recording can be useful when you need to quickly create a test that tests the basic functionality of an application or feature, but does not require long-term maintenance.