QTP Scripts

Data Driven Testing Scripts

1)Data Driven Testing for Login Operation by fetching Test data directly from a text file

2) Data Driven Testing for Login Operation by fetching from an excel file
3) Data Driven Testing by fetching Test data from a Database  
QTP Scripts 2
‘Test Requirement: Open 1 to 10 records in FR window, Capture and export Order No and Customer Names to a text file
QTP Script 3
QTP Script 4
QTP Script 5
QTP Script 6
QTP Script 7
QTP Script 8
QTP Script 9
QTP Script 10
QTP Script 11———————————————————

XML Scripts

a) .How to Load an XML File in QTP?

‘Microsoft.XMLDOM is a COM object of Microsoft’s XML parse
Set objxml=createobject(“Microsoft.XMLDOM”)
‘Async property specifies whether asynchronous download of the document is permitted or not
objxml.Async = False
‘objxml.Load”Path of the file”
‘2.How to get No. of Nodes in an Xml File?
Set mynodes = objxml.SelectNodes(“/libray/book”)
msgbox “TotalBooks:”&mynodes.Length
‘3.How to get titles of all books names in a library?
Set mynodes = objxml.SelectNodes(“/library/book/title/text()”)
‘ get their values
For i = 0 To (nodes.Length – 1)
BookName = mynodes(i).NodeValue
MsgBox “BookName #” & (i + 1) & “: ” & Title
‘4.How to get title of the Specific book?
‘book[No.of the Node in the xml file]
Set mynode = objxml.SelectSingleNode(“/bookstore/book[3]/title/text()”)
MsgBox “Title of Specific book: ” & mynode.NodeValue
‘5.How to get titles of all Specific Author books?
Set nodes = xmlDoc.SelectNodes(“/bookstore/book/title[../author = ‘Nagesh QTP10.0′]/text()”)
For i = 0 To (nodes.Length – 1)
BookTitle = nodes(i).NodeValue
MsgBox “BookTitle #” & (i + 1) & ”   ” & BookTitle
 Adding Hyperlink in Excel sheet

Dim objExcel, myFile, mySheet
Set objExcel=CreateObject(“Excel.Application”)

Set myFile=objExcel.WorkBooks.Open(“C:Documents and SettingsbannuDesktopGcreddy.xls”)
Set mySheet=myFile.Worksheets(1)

mySheet.Hyperlinks.Add .Range(“A1″),”http://www.gcreddy.com/”

Set objExcel=Nothing