Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
QTP Excel Scripting

QTP Excel Scripting

Ratings:
(0)
|Views: 479|Likes:
Published by G.C.Reddy
QTP Excel Scripting Examples;
'Objects in Excel Object Model
a) Excel Application - Excel Application Object
b Excel Workbook / File - Workbook Object
c) Excel Worksheet / sheet - Worksheet
Important Operations on Excel files for Test Automation Using QuickTest Professional (QTP)
a) Create Excel Files
b) Open Excel Files
c) Copy Excel Files
d) Delete Excel Files
e) Move Excel Files
f) Read Data
e) Read Data for Data driven Testing
f) Write Data
g) Write Test Result
h) Comparing data (One to one)
i) Comparing data (One to Many)
j) Comparing data (Many to one)
k) Comparing data (Many to Many Exact)
l) Comparing data (Many to Many Textual)
m) Searching for strings
QTP Excel Scripting Examples;
'Objects in Excel Object Model
a) Excel Application - Excel Application Object
b Excel Workbook / File - Workbook Object
c) Excel Worksheet / sheet - Worksheet
Important Operations on Excel files for Test Automation Using QuickTest Professional (QTP)
a) Create Excel Files
b) Open Excel Files
c) Copy Excel Files
d) Delete Excel Files
e) Move Excel Files
f) Read Data
e) Read Data for Data driven Testing
f) Write Data
g) Write Test Result
h) Comparing data (One to one)
i) Comparing data (One to Many)
j) Comparing data (Many to one)
k) Comparing data (Many to Many Exact)
l) Comparing data (Many to Many Textual)
m) Searching for strings

More info:

Published by: G.C.Reddy on Sep 09, 2011
Copyright:Public Domain

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

11/26/2012

pdf

text

original

 
www.gcreddy.comVisit:
www.gcreddy.com
for QTP Information
Excel File / Work Book Operations
--------------------------------------------------'Objects in Excel Object Modela) Excel Application - Excel Application Objectb) Excel Workbook / File- Workbook Objectc) Excel Worksheet / sheet - Worksheet------------------------------------------------------Note: Without creating Work Book Object and Work Sheet Object,we can perform all Excel Application Operations using ExcelApplication(Main) Object, but for user friendliness we use thoseobjects.'Creating Excel Application ObjectSet Variable=CreateObject("Excel.Application")
'Create ExcelApplication ObjectDim objExcelSet objExcel=CreateObject("Excel.Application")Important Operations on Excel files for Test Automation Using
QuickTestProfessional (QTP)
a) Create Excel Filesb) Open Excel Files
www.gcreddy.com
1
 
www.gcreddy.com
c) Copy Excel Filesd) Delete Excel Filese) Move Excel Filesf) Read Datae) Read Data for Data driven Testingf) Write Datag) Write Test Resulth) Comparing data (One to one)i) Comparing data (One to Many) j) Comparing data (Many to one)k) Comparing data (Many to Many Exact)l) Comparing data (Many to Many Textual)m) Searching for strings
Examples:
---------------------------------------------
1) 'Create Excel file /Work book
Dim objExcelSet objExcel=CreateObject("Excel.Application")objExcel.Visible=True 'To view the OperationsobjExcel.Workbooks.Add 'Creatining Excel file / workbookobjExcel.ActiveWorkbook.SaveAs "C:\Documents andSettings\Administrator\Desktop\gcreddy.xls"objExcel.Quit 'To Quit the Excel ApplicationSet objExcel=Nothing-----------------------------------------------------------
www.gcreddy.com
2
 
www.gcreddy.com
2) 'Check the existence of the File If exists then open the file andenter some data
' If Not exists Create the Excel file /Work book and enter some dataDim objExcel, objFso, FilePathFilePath="C:\Documents andSettings\Administrator\Desktop\gcreddy.xls"Set objFso=CreateObject("Scripting.FileSystemObject")Set objExcel=CreateObject("Excel.Application")If objFso.FileExists(FilePath) ThenobjExcel.Workbooks.Open (FilePath)objExcel.Worksheets("Sheet1").Cells(1,1)="VB Script"objExcel.ActiveWorkbook.SaveElseobjExcel.Workbooks.AddobjExcel.ActiveSheet.Cells(2,2)="VB Script"objExcel.ActiveWorkbook.SaveAs (Filepath)End If objExcel.Quit 'To Quit the Excel ApplictionSet objExcel=Nothing------------------------------------------------------
3) 'Fetch Test Data directly from an Excel file and perform Datadriven testing for Login Operation
Dim objExcel, objWorkbook, objWorksheet'Create Excel application Object that can be used to perform operationson Excel ApplictionSet objExcel=CreateObject("Excel.Application")'Create WorkBook Object using Excel application Object that can be usedto perform operations on Excel Work BooksSet objWorkbook=objExcel.Workbooks.Open ("C:\Documents andSettings\Administrator\Desktop\input.xls")'Create Work sheet object Using Work Book Object, that can be used toperform operations on Excel SheetsSet objWorksheet=objWorkbook.Worksheets("Sheet1")Rows_Count=objWorksheet.usedrange.rows.countFor i= 2 to Rows_Count Step 1SystemUtil.Run "C:\Program Files\HP\QuickTestProfessional\samples\flight\app\flight4a.exe","","C:\ProgramFiles\HP\QuickTest Professional\samples\flight\app\","open"
www.gcreddy.com
3

Activity (5)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Kavitha Adi liked this
Ting Zhang liked this
Sai Krishna liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->