SlideShare une entreprise Scribd logo
1  sur  15
www.gcreddy.com




                                  Visit:

      www.gcreddy.com
                         for QTP Information

           Excel Scripting in QTP
Excel File / Work Book Operations
--------------------------------------------------
'Objects in Excel Object Model

a) Excel Application - Excel Application Object

b) Excel Workbook / File       - Workbook Object

c) Excel Worksheet / sheet            - Worksheet

------------------------------------------------------
Note: Without creating Work Book Object and Work Sheet Object,
we can perform all Excel Application Operations using Excel
Application(Main) Object, but for user friendliness we use those
objects.

'Creating Excel Application Object

Set Variable=CreateObject("Excel.Application")'Create Excel
Application Object
Dim objExcel
Set objExcel=CreateObject("Excel.Application")

Important Operations on Excel files for Test Automation Using QuickTest
Professional (QTP)

a) Create Excel Files

b) Open Excel Files


                        www.gcreddy.com                               1
www.gcreddy.com

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


                           Examples:
---------------------------------------------
1) 'Create Excel file /Work book
Dim objExcel
Set objExcel=CreateObject("Excel.Application")
objExcel.Visible=True 'To view the Operations
objExcel.Workbooks.Add 'Creatining Excel file / workbook
objExcel.ActiveWorkbook.SaveAs "C:Documents and
SettingsAdministratorDesktopgcreddy.xls"

objExcel.Quit 'To Quit the Excel Application
Set objExcel=Nothing

-----------------------------------------------------------




                        www.gcreddy.com                       2
www.gcreddy.com
2) 'Check the existence of the File If exists then open the file and
enter some data

' If Not exists Create the Excel file /Work book and enter some data
Dim objExcel, objFso, FilePath
FilePath="C:Documents and
SettingsAdministratorDesktopgcreddy.xls"
Set objFso=CreateObject("Scripting.FileSystemObject")
Set objExcel=CreateObject("Excel.Application")

If objFso.FileExists(FilePath) Then
       objExcel.Workbooks.Open (FilePath)
       objExcel.Worksheets("Sheet1").Cells(1,1)="VB Script"
       objExcel.ActiveWorkbook.Save
       Else
       objExcel.Workbooks.Add
       objExcel.ActiveSheet.Cells(2,2)="VB Script"
       objExcel.ActiveWorkbook.SaveAs (Filepath)
End If

objExcel.Quit 'To Quit the Excel Appliction
Set objExcel=Nothing
------------------------------------------------------

3) 'Fetch Test Data directly from an Excel file and perform Data
driven testing for Login Operation

Dim objExcel, objWorkbook, objWorksheet
'Create Excel application Object that can be used to perform operations
on Excel Appliction
Set objExcel=CreateObject("Excel.Application")
'Create WorkBook Object using Excel application Object that can be used
to perform operations on Excel Work Books
Set objWorkbook=objExcel.Workbooks.Open ("C:Documents and
SettingsAdministratorDesktopinput.xls")
'Create Work sheet object Using Work Book Object, that can be used to
perform operations on Excel Sheets
Set objWorksheet=objWorkbook.Worksheets("Sheet1")
Rows_Count=objWorksheet.usedrange.rows.count

For i= 2 to Rows_Count Step 1
SystemUtil.Run "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe","","C:Program
FilesHPQuickTest Professionalsamplesflightapp","open"


                       www.gcreddy.com                                    3
www.gcreddy.com
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set objWorksheet.Cells(i,"A")
Dialog("Login").WinEdit("Password:").Set objWorksheet.Cells(i,"B")
Wait 1
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Close

Next
objExcel.Quit
Set objWorksheet=Nothing
Set objWorkbook=Nothing
Set objExcel=Nothing
-------------------------------------------------------------------------
4) 'Fetch Test Data directly from an Excel file and perform Data
driven testing for Login Operation

'Export Test Results to the same file
Dim objExcel, objWorkbook, objWorksheet
'Create Excel application Object that can be used to perform operations
on Excel Appliction
Set objExcel=CreateObject("Excel.Application")
'Create WorkBook Object using Excel application Object that can be used
to perform operations on Excel Work Books
Set objWorkbook=objExcel.Workbooks.Open ("C:Documents and
SettingsAdministratorDesktopinput.xls")
'Create Work sheet object Using Work Book Object , that can be used to
perform operations on Excel Sheets
Set objWorksheet=objWorkbook.Worksheets("Sheet1")
objWorksheet.Cells(1,3)="Results"
Rows_Count=objWorksheet.usedrange.rows.count

For i= 2 to Rows_Count Step 1
SystemUtil.Run "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe","","C:Program
FilesHPQuickTest Professionalsamplesflightapp","open"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set objWorksheet.Cells(i,"A")
Dialog("Login").WinEdit("Password:").Set objWorksheet.Cells(i,"B")
Wait 1
Dialog("Login").WinButton("OK").Click

If Window("Flight Reservation").Exist(12) Then
      Window("Flight Reservation").Close
      objWorksheet.Cells(i,"C")="Login Successful"


                      www.gcreddy.com                                       4
www.gcreddy.com
      Else
SystemUtil.CloseDescendentProcesses
objWorksheet.Cells(i,"C")="Login Filed"
End If

Next
objWorkbook.Save
objExcel.Quit
Set objWorksheet=Nothing
Set objWorkbook=Nothing
Set objExcel=Nothing

5) 'Fetch Test Data directly from an Excel file and perform Data
driven testing for Login Operation

'Export Test Results & Error Messgae to the same file
Dim objExcel, objWorkbook, objWorksheet, rows_Count

Set objExcel=CreateObject("Excel.Application")
Set objWorkbook=objExcel.Workbooks.Open ("C:Documents and
SettingsAdministratorDesktopinput.xls")
Set objWorksheet=objWorkbook.Worksheets(1)

objWorksheet.Cells(1,3)="Test Result"
objWorksheet.Cells(1,4)="Error Message"

rows_Count=objWorksheet.usedrange.rows.count

For i= 2 to rows_Count Step 1
      SystemUtil.Run "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe","","C:Program
FilesHPQuickTest Professionalsamplesflightapp","open"
      Dialog("Login").Activate
      Dialog("Login").WinEdit("Agent Name:").Set objWorksheet.Cells(i,
1)
      Dialog("Login").WinEdit("Password:").Set objWorksheet.Cells(i, "B")
      Dialog("Login").WinButton("OK").Click

If Window("Flight Reservation").Exist(12) Then
           Window("Flight Reservation").Close
objWorksheet.Cells(i, 3)="Login Successful"
Else
objWorksheet.Cells(i, 3)="Login Failed"



                     www.gcreddy.com                                    5
www.gcreddy.com
objWorksheet.Cells(i, 4)=Dialog("Login").Dialog("Flight
Reservations").Static("Agent name must be at").GetROProperty ("text")
SystemUtil.CloseDescendentProcesses
End If
Next

objWorkbook.Save
objExcel.Quit
Set objWorksheet=Nothing
Set objWorkbook=Nothing
Set objExcel=Nothing
6)
Using While...Wend Loop
------------------------
Dim objExcel, objWorkbook, objWorksheet, rows_Count, i

Set objExcel=CreateObject("Excel.Application")
Set objWorkbook=objExcel.Workbooks.Open ("C:Documents and
SettingsAdministratorDesktopinput.xls")
Set objWorksheet=objWorkbook.Worksheets(1)

objWorksheet.Cells(1,3)="Test Result"
objWorksheet.Cells(1,4)="Error Message"

rows_Count=objWorksheet.usedrange.rows.count
 i= 2
While i<= rows_Count
      SystemUtil.Run "C:Program FilesHPQuickTest
Professionalsamplesflightappflight4a.exe","","C:Program
FilesHPQuickTest Professionalsamplesflightapp","open"
      Dialog("Login").Activate
      Dialog("Login").WinEdit("Agent Name:").Set objWorksheet.Cells(i,
1)
      Dialog("Login").WinEdit("Password:").Set objWorksheet.Cells(i, "B")
      Dialog("Login").WinButton("OK").Click

If Window("Flight Reservation").Exist(12) Then
           Window("Flight Reservation").Close
objWorksheet.Cells(i, 3)="Login Successful"
Else
objWorksheet.Cells(i, 3)="Login Failed"
objWorksheet.Cells(i, 4)=Dialog("Login").Dialog("Flight
Reservations").Static("Agent name must be at").GetROProperty ("text")
SystemUtil.CloseDescendentProcesses


                     www.gcreddy.com                                    6
www.gcreddy.com
End If
i=i+1
Wend

objWorkbook.Save
objExcel.Quit
Set objWorksheet=Nothing
Set objWorkbook=Nothing
Set objExcel=Nothing

7) 'Capture Link names from Google home page and export to
Excel file 3rd sheet

Dim ObjExcel,ObjWorkbook,ObjWorksheet
Dim oLink,Links,myLink,i

Set ObjExcel=CreateObject("Excel.Application")

Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and
SettingsAdministratorDesktopinput.xls")

Set ObjWorksheet=ObjWorkbook.Worksheets(3)
      ObjWorksheet.Cells(1,1)="Link Names"
Set oLink=Description.Create

oLink("micclass").value="Link"

Set
Links=Browser("title:=Google").Page("title:=Google").ChildObjects(oLink
)

For i=0 to Links.Count-1 step 1

       myLink=Links(i).GetRoProperty("text")
       ObjWorksheet.Cells(i+2,1)=myLink
Next

ObjWorkbook.Save

ObjExcel.Quit

Set ObjWorksheet=Nothing

Set ObjWorkbook=Nothing


                     www.gcreddy.com                                  7
www.gcreddy.com

Set ObjExcel=Nothing
----------------------------------------------------------------------------------
8) 'Capture Button names from Login Dialog (Flight Reservation
Application) and export to Excel file 3rd sheet

Dim ObjExcel,ObjWorkbook,ObjWorksheet
Dim oButton,Buttons,myButton,i

Set ObjExcel=CreateObject("Excel.Application")
Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and
SettingsAdministratorDesktopinput.xls")
Set ObjWorksheet=ObjWorkbook.Worksheets(2)

      ObjWorksheet.Cells(1,1)="Button Names"

Set oButton=Description.Create
oButton("Class Name").value="WinButton"
Set Buttons=Dialog("text:=Login").ChildObjects(oButton)

For i=0 to Buttons.Count-1 step 1
      myButton=Buttons(i).GetRoProperty("text")
      ObjWorksheet.Cells(i+2,1)=myButton
Next

ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing
----------------------------------------------------------------------------------
-
9) ' Read/capture order numbers and customer names from 1 - 10
orders in Flight Reservation window

' and export to excel file 2nd sheet
Dim objExcel, objWorkBook, objWorkSheet, ord, C_Name
Set objExcel = createobject("Excel.Application")
Set objWorkBook = objExcel.Workbooks.Open("C:Documents and
SettingsgcrDesktopSample.xls")
Set objWorkSheet = objWorkBook.Worksheets(2)
objWorkSheet.cells(1,1) = "Order No."
objWorkSheet.cells(1,2) = "C-Name"



                       www.gcreddy.com                                           8
www.gcreddy.com
For ord= 1 to 10 Step 1
      Window("Flight Reservation").Activate
      Window("Flight Reservation").WinButton("Button").Click
      Window("Flight Reservation").Dialog("Open
Order").WinCheckBox("Order No.").Set "ON"
      Window("Flight Reservation").Dialog("Open
Order").WinEdit("Edit").Set ord
      Window("Flight Reservation").Dialog("Open
Order").WinButton("OK").Click
      Wait 1
      C_Name = Window("Flight
Reservation").WinEdit("Name:").GetROProperty("text")
objWorkSheet.cells(ord+1,1) = ord
objWorkSheet.cells(ord+1,2) =C_Name
Next

objWorkBook.Save
objExcel.Quit
Set objWorkSheet=Nothing
Set objWorkBook=Nothing
Set objExcel=Nothing

10) One to One Comparison and Exact match
----------------------------------------
'Capture Button names from Login Dialog (Flight Reservation
Application) and Perform One to One Comparison and Exact match

Dim ObjExcel,ObjWorkbook,ObjWorksheet
Dim oButton,Buttons,myButton,i

Set ObjExcel=CreateObject("Excel.Application")
Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and
SettingsAdministratorDesktopinput.xls")
Set ObjWorksheet=ObjWorkbook.Worksheets(2)

     ObjWorksheet.Cells(1,2)="Buttons"

Set oButton=Description.Create
oButton("Class Name").value="WinButton"
Set Buttons=Dialog("text:=Login").ChildObjects(oButton)

For i=0 to Buttons.Count-1 step 1
      myButton=Buttons(i).GetRoProperty("text")
      ObjWorksheet.Cells(i+2, 2)=myButton


                    www.gcreddy.com                              9
www.gcreddy.com
Next
rows_Count= ObjWorksheet.usedrange.rows.count
For j= 2 to rows_Count step 1
Expected=ObjWorksheet.Cells(j, 1)
Actual=ObjWorksheet.Cells(j, 2)

If Expected=Actual Then
ObjWorksheet.Cells(j, 3)="Pass"
Else
ObjWorksheet.Cells(j, 3)="Fail"
End If
Next

ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing

11) One to One Textual Comparison
------------------------------
'Capture Button names from Login Dialog (Flight Reservation
Application) and Perform and Perform One to One Textual Comparison

Dim ObjExcel,ObjWorkbook,ObjWorksheet
Dim oButton,Buttons,myButton,i

Set ObjExcel=CreateObject("Excel.Application")
Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and
SettingsAdministratorDesktopinput.xls")
Set ObjWorksheet=ObjWorkbook.Worksheets(2)

     ObjWorksheet.Cells(1,2)="Buttons"

Set oButton=Description.Create
oButton("Class Name").value="WinButton"
Set Buttons=Dialog("text:=Login").ChildObjects(oButton)

For i=0 to Buttons.Count-1 step 1
      myButton=Buttons(i).GetRoProperty("text")
      ObjWorksheet.Cells(i+2, 2)=myButton
Next
rows_Count= ObjWorksheet.usedrange.rows.count
For j= 2 to rows_Count step 1


                    www.gcreddy.com                             10
www.gcreddy.com
Expected=ObjWorksheet.Cells(j, 1)
Actual=ObjWorksheet.Cells(j, 2)

If StrComp (Expected,Actual,1)=0 Then
ObjWorksheet.Cells(j, 3)="Pass"
Else
ObjWorksheet.Cells(j, 3)="Fail"
End If
Next

ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing
--------------------------------------------------------------------------
12) Many to Many Comparison
-----------------------------------
'Capture Button names from Login Dialog (Flight Reservation
Application) and Perform and Perform Many to Many Comparison

Dim ObjExcel,ObjWorkbook,ObjWorksheet
Dim oButton,Buttons,myButton,i

Set ObjExcel=CreateObject("Excel.Application")
Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and
SettingsAdministratorDesktopinput.xls")
Set ObjWorksheet=ObjWorkbook.Worksheets(2)

      ObjWorksheet.Cells(1,2)="Buttons"

Set oButton=Description.Create
oButton("Class Name").value="WinButton"
Set Buttons=Dialog("text:=Login").ChildObjects(oButton)

For i=0 to Buttons.Count-1 step 1
      myButton=Buttons(i).GetRoProperty("text")
      ObjWorksheet.Cells(i+2, 2)=myButton
Next
rows_Count= ObjWorksheet.usedrange.rows.count

For j= 2 to rows_Count step 1
Expected=ObjWorksheet.Cells(j, 1)



                       www.gcreddy.com                                       11
www.gcreddy.com
For k=2 to rows_Count step 1
      Actual=ObjWorksheet.Cells(k, 2)

 If Expected=Actual Then
       Flag =1
       Exit for
       else
       Flag= 0
 End If
next

If Flag=1 Then
ObjWorksheet.Cells(j, 3)="Pass"
Else
ObjWorksheet.Cells(j, 3)="Fail"
End If
Next

ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing

-------------------------------------------------------------------
13) Many to Many Textual Comparison

'Capture Button names from Login Dialog (Flight Reservation
Application) and Perform and Perform Many to Many Textual
Comparison

-----------------------------------
'Capture Button names from Google home page and export to Excel file
3rd sheet

Dim ObjExcel,ObjWorkbook,ObjWorksheet
Dim oButton,Buttons,myButton,i

Set ObjExcel=CreateObject("Excel.Application")
Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and
SettingsAdministratorDesktopinput.xls")
Set ObjWorksheet=ObjWorkbook.Worksheets(2)

      ObjWorksheet.Cells(1,2)="Buttons"


                       www.gcreddy.com                                 12
www.gcreddy.com

Set oButton=Description.Create
oButton("Class Name").value="WinButton"
Set Buttons=Dialog("text:=Login").ChildObjects(oButton)

For i=0 to Buttons.Count-1 step 1
      myButton=Buttons(i).GetRoProperty("text")
      ObjWorksheet.Cells(i+2, 2)=myButton
Next
rows_Count= ObjWorksheet.usedrange.rows.count

For j= 2 to rows_Count step 1
Expected=ObjWorksheet.Cells(j, 1)

For k=2 to rows_Count step 1
      Actual=ObjWorksheet.Cells(k, 2)

 If StrComp (Expected,Actual,1)= 0 Then
       Flag =1
       Exit for
       else
       Flag= 0
 End If
next

If Flag=1 Then
ObjWorksheet.Cells(j, 3)="Pass"
Else
ObjWorksheet.Cells(j, 3)="Fail"
End If
Next

ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing
----------------------------------------------------------------------------------
-----

14) 'Create Excel file and Rename 1st sheet as "Module", 2nd
Sheet as "Test Case", 'and 3rd Sheet as "Test Step"
Dim objExcel
Set objExcel=CreateObject("Excel.Application")


                       www.gcreddy.com                                          13
www.gcreddy.com
objExcel.Visible=True
objExcel.Workbooks.Add
objExcel.Worksheets("Sheet1").Name="Module"
Wait 4
objExcel.Worksheets("Sheet2").Name="TestCase"
Wait 4
objExcel.Worksheets("Sheet3").Name="TestStep"

objExcel.ActiveWorkbook.SaveAs "C:Documents and
SettingsAdministratorDesktopabcd.xls"

objExcel.Quit
Set objExcel=Nothing
-------------------------------------------------------------------------
15) 'Create an Excel file and add one more

Dim objExcel
Set objExcel=CreateObject("Excel.Application")
objExcel.Visible=True
objExcel.Workbooks.Add 'Creating Work Book
objExcel.Worksheets.Add 'Creating Work Sheet
Wait 4
objExcel.ActiveWorkbook.SaveAs "C:Documents and
SettingsAdministratorDesktopabcde.xls"

objExcel.Quit
Set objExcel=Nothing
----------------------------------------------------------------------------------
----
15) 'Capture Button names from Login Dialog (Flight Reservation
Application) and perform Many to Many Complete Comparison

Capture Button names from Google home page and export to Excel file
3rd sheet

Dim ObjExcel,ObjWorkbook,ObjWorksheet
Dim oButton,Buttons,myButton,i

Set ObjExcel=CreateObject("Excel.Application")
Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and
SettingsAdministratorDesktopinput.xls")
Set ObjWorksheet=ObjWorkbook.Worksheets(2)

      ObjWorksheet.Cells(1,2)="Buttons"


                       www.gcreddy.com                                          14
www.gcreddy.com

Set oButton=Description.Create
oButton("Class Name").value="WinButton"
Set Buttons=Dialog("text:=Login").ChildObjects(oButton)

For i=0 to Buttons.Count-1 step 1
      myButton=Buttons(i).GetRoProperty("text")
      ObjWorksheet.Cells(i+2, 2)=myButton
Next
rows_Count= ObjWorksheet.usedrange.rows.count

x =0

For j= 2 to rows_Count step 1
      Expected=ObjWorksheet.Cells(j, 1)
      flag = 0
      For k=2 to rows_Count step 1
            Actual=ObjWorksheet.Cells(k, 2)
            If StrComp (Expected,Actual,1)= 0 Then
            Flag =1
            End If
            x=x+1 ' increment the comparison count
      next

       If Flag=1 Then
             ObjWorksheet.Cells(j, 3)="Pass"
       Else
             ObjWorksheet.Cells(j, 3)="Fail"
       End If
       msgbox x 'inner loop comparison values
Next
       msgbox x ' Total number of comparisons

ObjWorkbook.Save
ObjExcel.Quit
Set ObjWorksheet=Nothing
Set ObjWorkbook=Nothing
Set ObjExcel=Nothing




                     www.gcreddy.com                      15

Contenu connexe

Tendances

The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 20 of 88
The Ring programming language version 1.3 book - Part 20 of 88The Ring programming language version 1.3 book - Part 20 of 88
The Ring programming language version 1.3 book - Part 20 of 88Mahmoud Samir Fayed
 
Adodb Scripts And Some Sample Scripts[1]
Adodb Scripts And Some Sample Scripts[1]Adodb Scripts And Some Sample Scripts[1]
Adodb Scripts And Some Sample Scripts[1]User1test
 
The Ring programming language version 1.9 book - Part 46 of 210
The Ring programming language version 1.9 book - Part 46 of 210The Ring programming language version 1.9 book - Part 46 of 210
The Ring programming language version 1.9 book - Part 46 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 31 of 189
The Ring programming language version 1.6 book - Part 31 of 189The Ring programming language version 1.6 book - Part 31 of 189
The Ring programming language version 1.6 book - Part 31 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 43 of 202
The Ring programming language version 1.8 book - Part 43 of 202The Ring programming language version 1.8 book - Part 43 of 202
The Ring programming language version 1.8 book - Part 43 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212Mahmoud Samir Fayed
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF Luc Bors
 
WorkingWithSlick2.1.0
WorkingWithSlick2.1.0WorkingWithSlick2.1.0
WorkingWithSlick2.1.0Knoldus Inc.
 
The Ring programming language version 1.5.2 book - Part 28 of 181
The Ring programming language version 1.5.2 book - Part 28 of 181The Ring programming language version 1.5.2 book - Part 28 of 181
The Ring programming language version 1.5.2 book - Part 28 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88Mahmoud Samir Fayed
 

Tendances (19)

The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180The Ring programming language version 1.5.1 book - Part 27 of 180
The Ring programming language version 1.5.1 book - Part 27 of 180
 
Functions
FunctionsFunctions
Functions
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
 
The Ring programming language version 1.3 book - Part 20 of 88
The Ring programming language version 1.3 book - Part 20 of 88The Ring programming language version 1.3 book - Part 20 of 88
The Ring programming language version 1.3 book - Part 20 of 88
 
Adodb Scripts And Some Sample Scripts[1]
Adodb Scripts And Some Sample Scripts[1]Adodb Scripts And Some Sample Scripts[1]
Adodb Scripts And Some Sample Scripts[1]
 
The Ring programming language version 1.9 book - Part 46 of 210
The Ring programming language version 1.9 book - Part 46 of 210The Ring programming language version 1.9 book - Part 46 of 210
The Ring programming language version 1.9 book - Part 46 of 210
 
The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189
 
The Ring programming language version 1.6 book - Part 31 of 189
The Ring programming language version 1.6 book - Part 31 of 189The Ring programming language version 1.6 book - Part 31 of 189
The Ring programming language version 1.6 book - Part 31 of 189
 
The Ring programming language version 1.8 book - Part 43 of 202
The Ring programming language version 1.8 book - Part 43 of 202The Ring programming language version 1.8 book - Part 43 of 202
The Ring programming language version 1.8 book - Part 43 of 202
 
Green dao
Green daoGreen dao
Green dao
 
The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185
 
The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212
 
Mongo db for c# developers
Mongo db for c# developersMongo db for c# developers
Mongo db for c# developers
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF
 
WorkingWithSlick2.1.0
WorkingWithSlick2.1.0WorkingWithSlick2.1.0
WorkingWithSlick2.1.0
 
The Ring programming language version 1.5.2 book - Part 28 of 181
The Ring programming language version 1.5.2 book - Part 28 of 181The Ring programming language version 1.5.2 book - Part 28 of 181
The Ring programming language version 1.5.2 book - Part 28 of 181
 
Green dao
Green daoGreen dao
Green dao
 
The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196
 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88
 

Similaire à Excel Scripting

File System Operations
File System OperationsFile System Operations
File System OperationsG.C Reddy
 
Qtp Imp Script Examples
Qtp Imp Script ExamplesQtp Imp Script Examples
Qtp Imp Script ExamplesUser1test
 
How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...Priyobroto Ghosh (Mule ESB Certified)
 
descriptive programming
descriptive programmingdescriptive programming
descriptive programmingAnand Dhana
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84Mahmoud Samir Fayed
 
Scripting as a Second Language
Scripting as a Second LanguageScripting as a Second Language
Scripting as a Second LanguageRob Dunn
 
Parameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple inputParameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple inputuanna
 
The Ring programming language version 1.5.1 book - Part 36 of 180
The Ring programming language version 1.5.1 book - Part 36 of 180The Ring programming language version 1.5.1 book - Part 36 of 180
The Ring programming language version 1.5.1 book - Part 36 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196Mahmoud Samir Fayed
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Knoldus Inc.
 
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Neelkanth Sachdeva
 
Nosql hands on handout 04
Nosql hands on handout 04Nosql hands on handout 04
Nosql hands on handout 04Krishna Sankar
 
Adodb Scripts And Some Sample Scripts[1]
Adodb Scripts And Some Sample Scripts[1]Adodb Scripts And Some Sample Scripts[1]
Adodb Scripts And Some Sample Scripts[1]testduser1
 
EPiServer report generation
EPiServer report generationEPiServer report generation
EPiServer report generationPaul Graham
 

Similaire à Excel Scripting (20)

Examplecode
ExamplecodeExamplecode
Examplecode
 
File System Operations
File System OperationsFile System Operations
File System Operations
 
QTP
QTPQTP
QTP
 
Qtp Imp Script Examples
Qtp Imp Script ExamplesQtp Imp Script Examples
Qtp Imp Script Examples
 
How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...How to execute an oracle stored procedure with nested table as a parameter fr...
How to execute an oracle stored procedure with nested table as a parameter fr...
 
descriptive programming
descriptive programmingdescriptive programming
descriptive programming
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84
 
Python openpyxl
Python openpyxlPython openpyxl
Python openpyxl
 
Scripting as a Second Language
Scripting as a Second LanguageScripting as a Second Language
Scripting as a Second Language
 
Parameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple inputParameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple input
 
The Ring programming language version 1.5.1 book - Part 36 of 180
The Ring programming language version 1.5.1 book - Part 36 of 180The Ring programming language version 1.5.1 book - Part 36 of 180
The Ring programming language version 1.5.1 book - Part 36 of 180
 
Qtp test
Qtp testQtp test
Qtp test
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
 
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala Traits Event , New Delh...
 
Html web sql database
Html web sql databaseHtml web sql database
Html web sql database
 
Nosql hands on handout 04
Nosql hands on handout 04Nosql hands on handout 04
Nosql hands on handout 04
 
Adodb Scripts And Some Sample Scripts[1]
Adodb Scripts And Some Sample Scripts[1]Adodb Scripts And Some Sample Scripts[1]
Adodb Scripts And Some Sample Scripts[1]
 
Excel
ExcelExcel
Excel
 
EPiServer report generation
EPiServer report generationEPiServer report generation
EPiServer report generation
 

Plus de G C Reddy Technologies (8)

Manual testing
Manual testingManual testing
Manual testing
 
Free Classified Ads
Free Classified AdsFree Classified Ads
Free Classified Ads
 
Load runner
Load runnerLoad runner
Load runner
 
Qtp launch
Qtp launchQtp launch
Qtp launch
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Sql functions
Sql functionsSql functions
Sql functions
 
Qtp Resume
Qtp ResumeQtp Resume
Qtp Resume
 
Qtp Resume
Qtp ResumeQtp Resume
Qtp Resume
 

Dernier

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 

Dernier (20)

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 

Excel Scripting

  • 1. www.gcreddy.com Visit: www.gcreddy.com for QTP Information Excel Scripting in QTP Excel File / Work Book Operations -------------------------------------------------- 'Objects in Excel Object Model a) Excel Application - Excel Application Object b) Excel Workbook / File - Workbook Object c) Excel Worksheet / sheet - Worksheet ------------------------------------------------------ Note: Without creating Work Book Object and Work Sheet Object, we can perform all Excel Application Operations using Excel Application(Main) Object, but for user friendliness we use those objects. 'Creating Excel Application Object Set Variable=CreateObject("Excel.Application")'Create Excel Application Object Dim objExcel Set objExcel=CreateObject("Excel.Application") Important Operations on Excel files for Test Automation Using QuickTest Professional (QTP) a) Create Excel Files b) Open Excel Files www.gcreddy.com 1
  • 2. www.gcreddy.com 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 Examples: --------------------------------------------- 1) 'Create Excel file /Work book Dim objExcel Set objExcel=CreateObject("Excel.Application") objExcel.Visible=True 'To view the Operations objExcel.Workbooks.Add 'Creatining Excel file / workbook objExcel.ActiveWorkbook.SaveAs "C:Documents and SettingsAdministratorDesktopgcreddy.xls" objExcel.Quit 'To Quit the Excel Application Set objExcel=Nothing ----------------------------------------------------------- www.gcreddy.com 2
  • 3. www.gcreddy.com 2) 'Check the existence of the File If exists then open the file and enter some data ' If Not exists Create the Excel file /Work book and enter some data Dim objExcel, objFso, FilePath FilePath="C:Documents and SettingsAdministratorDesktopgcreddy.xls" Set objFso=CreateObject("Scripting.FileSystemObject") Set objExcel=CreateObject("Excel.Application") If objFso.FileExists(FilePath) Then objExcel.Workbooks.Open (FilePath) objExcel.Worksheets("Sheet1").Cells(1,1)="VB Script" objExcel.ActiveWorkbook.Save Else objExcel.Workbooks.Add objExcel.ActiveSheet.Cells(2,2)="VB Script" objExcel.ActiveWorkbook.SaveAs (Filepath) End If objExcel.Quit 'To Quit the Excel Appliction Set objExcel=Nothing ------------------------------------------------------ 3) 'Fetch Test Data directly from an Excel file and perform Data driven testing for Login Operation Dim objExcel, objWorkbook, objWorksheet 'Create Excel application Object that can be used to perform operations on Excel Appliction Set objExcel=CreateObject("Excel.Application") 'Create WorkBook Object using Excel application Object that can be used to perform operations on Excel Work Books Set objWorkbook=objExcel.Workbooks.Open ("C:Documents and SettingsAdministratorDesktopinput.xls") 'Create Work sheet object Using Work Book Object, that can be used to perform operations on Excel Sheets Set objWorksheet=objWorkbook.Worksheets("Sheet1") Rows_Count=objWorksheet.usedrange.rows.count For i= 2 to Rows_Count Step 1 SystemUtil.Run "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe","","C:Program FilesHPQuickTest Professionalsamplesflightapp","open" www.gcreddy.com 3
  • 4. www.gcreddy.com Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set objWorksheet.Cells(i,"A") Dialog("Login").WinEdit("Password:").Set objWorksheet.Cells(i,"B") Wait 1 Dialog("Login").WinButton("OK").Click Window("Flight Reservation").Close Next objExcel.Quit Set objWorksheet=Nothing Set objWorkbook=Nothing Set objExcel=Nothing ------------------------------------------------------------------------- 4) 'Fetch Test Data directly from an Excel file and perform Data driven testing for Login Operation 'Export Test Results to the same file Dim objExcel, objWorkbook, objWorksheet 'Create Excel application Object that can be used to perform operations on Excel Appliction Set objExcel=CreateObject("Excel.Application") 'Create WorkBook Object using Excel application Object that can be used to perform operations on Excel Work Books Set objWorkbook=objExcel.Workbooks.Open ("C:Documents and SettingsAdministratorDesktopinput.xls") 'Create Work sheet object Using Work Book Object , that can be used to perform operations on Excel Sheets Set objWorksheet=objWorkbook.Worksheets("Sheet1") objWorksheet.Cells(1,3)="Results" Rows_Count=objWorksheet.usedrange.rows.count For i= 2 to Rows_Count Step 1 SystemUtil.Run "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe","","C:Program FilesHPQuickTest Professionalsamplesflightapp","open" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set objWorksheet.Cells(i,"A") Dialog("Login").WinEdit("Password:").Set objWorksheet.Cells(i,"B") Wait 1 Dialog("Login").WinButton("OK").Click If Window("Flight Reservation").Exist(12) Then Window("Flight Reservation").Close objWorksheet.Cells(i,"C")="Login Successful" www.gcreddy.com 4
  • 5. www.gcreddy.com Else SystemUtil.CloseDescendentProcesses objWorksheet.Cells(i,"C")="Login Filed" End If Next objWorkbook.Save objExcel.Quit Set objWorksheet=Nothing Set objWorkbook=Nothing Set objExcel=Nothing 5) 'Fetch Test Data directly from an Excel file and perform Data driven testing for Login Operation 'Export Test Results & Error Messgae to the same file Dim objExcel, objWorkbook, objWorksheet, rows_Count Set objExcel=CreateObject("Excel.Application") Set objWorkbook=objExcel.Workbooks.Open ("C:Documents and SettingsAdministratorDesktopinput.xls") Set objWorksheet=objWorkbook.Worksheets(1) objWorksheet.Cells(1,3)="Test Result" objWorksheet.Cells(1,4)="Error Message" rows_Count=objWorksheet.usedrange.rows.count For i= 2 to rows_Count Step 1 SystemUtil.Run "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe","","C:Program FilesHPQuickTest Professionalsamplesflightapp","open" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set objWorksheet.Cells(i, 1) Dialog("Login").WinEdit("Password:").Set objWorksheet.Cells(i, "B") Dialog("Login").WinButton("OK").Click If Window("Flight Reservation").Exist(12) Then Window("Flight Reservation").Close objWorksheet.Cells(i, 3)="Login Successful" Else objWorksheet.Cells(i, 3)="Login Failed" www.gcreddy.com 5
  • 6. www.gcreddy.com objWorksheet.Cells(i, 4)=Dialog("Login").Dialog("Flight Reservations").Static("Agent name must be at").GetROProperty ("text") SystemUtil.CloseDescendentProcesses End If Next objWorkbook.Save objExcel.Quit Set objWorksheet=Nothing Set objWorkbook=Nothing Set objExcel=Nothing 6) Using While...Wend Loop ------------------------ Dim objExcel, objWorkbook, objWorksheet, rows_Count, i Set objExcel=CreateObject("Excel.Application") Set objWorkbook=objExcel.Workbooks.Open ("C:Documents and SettingsAdministratorDesktopinput.xls") Set objWorksheet=objWorkbook.Worksheets(1) objWorksheet.Cells(1,3)="Test Result" objWorksheet.Cells(1,4)="Error Message" rows_Count=objWorksheet.usedrange.rows.count i= 2 While i<= rows_Count SystemUtil.Run "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe","","C:Program FilesHPQuickTest Professionalsamplesflightapp","open" Dialog("Login").Activate Dialog("Login").WinEdit("Agent Name:").Set objWorksheet.Cells(i, 1) Dialog("Login").WinEdit("Password:").Set objWorksheet.Cells(i, "B") Dialog("Login").WinButton("OK").Click If Window("Flight Reservation").Exist(12) Then Window("Flight Reservation").Close objWorksheet.Cells(i, 3)="Login Successful" Else objWorksheet.Cells(i, 3)="Login Failed" objWorksheet.Cells(i, 4)=Dialog("Login").Dialog("Flight Reservations").Static("Agent name must be at").GetROProperty ("text") SystemUtil.CloseDescendentProcesses www.gcreddy.com 6
  • 7. www.gcreddy.com End If i=i+1 Wend objWorkbook.Save objExcel.Quit Set objWorksheet=Nothing Set objWorkbook=Nothing Set objExcel=Nothing 7) 'Capture Link names from Google home page and export to Excel file 3rd sheet Dim ObjExcel,ObjWorkbook,ObjWorksheet Dim oLink,Links,myLink,i Set ObjExcel=CreateObject("Excel.Application") Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and SettingsAdministratorDesktopinput.xls") Set ObjWorksheet=ObjWorkbook.Worksheets(3) ObjWorksheet.Cells(1,1)="Link Names" Set oLink=Description.Create oLink("micclass").value="Link" Set Links=Browser("title:=Google").Page("title:=Google").ChildObjects(oLink ) For i=0 to Links.Count-1 step 1 myLink=Links(i).GetRoProperty("text") ObjWorksheet.Cells(i+2,1)=myLink Next ObjWorkbook.Save ObjExcel.Quit Set ObjWorksheet=Nothing Set ObjWorkbook=Nothing www.gcreddy.com 7
  • 8. www.gcreddy.com Set ObjExcel=Nothing ---------------------------------------------------------------------------------- 8) 'Capture Button names from Login Dialog (Flight Reservation Application) and export to Excel file 3rd sheet Dim ObjExcel,ObjWorkbook,ObjWorksheet Dim oButton,Buttons,myButton,i Set ObjExcel=CreateObject("Excel.Application") Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and SettingsAdministratorDesktopinput.xls") Set ObjWorksheet=ObjWorkbook.Worksheets(2) ObjWorksheet.Cells(1,1)="Button Names" Set oButton=Description.Create oButton("Class Name").value="WinButton" Set Buttons=Dialog("text:=Login").ChildObjects(oButton) For i=0 to Buttons.Count-1 step 1 myButton=Buttons(i).GetRoProperty("text") ObjWorksheet.Cells(i+2,1)=myButton Next ObjWorkbook.Save ObjExcel.Quit Set ObjWorksheet=Nothing Set ObjWorkbook=Nothing Set ObjExcel=Nothing ---------------------------------------------------------------------------------- - 9) ' Read/capture order numbers and customer names from 1 - 10 orders in Flight Reservation window ' and export to excel file 2nd sheet Dim objExcel, objWorkBook, objWorkSheet, ord, C_Name Set objExcel = createobject("Excel.Application") Set objWorkBook = objExcel.Workbooks.Open("C:Documents and SettingsgcrDesktopSample.xls") Set objWorkSheet = objWorkBook.Worksheets(2) objWorkSheet.cells(1,1) = "Order No." objWorkSheet.cells(1,2) = "C-Name" www.gcreddy.com 8
  • 9. www.gcreddy.com For ord= 1 to 10 Step 1 Window("Flight Reservation").Activate Window("Flight Reservation").WinButton("Button").Click Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON" Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set ord Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click Wait 1 C_Name = Window("Flight Reservation").WinEdit("Name:").GetROProperty("text") objWorkSheet.cells(ord+1,1) = ord objWorkSheet.cells(ord+1,2) =C_Name Next objWorkBook.Save objExcel.Quit Set objWorkSheet=Nothing Set objWorkBook=Nothing Set objExcel=Nothing 10) One to One Comparison and Exact match ---------------------------------------- 'Capture Button names from Login Dialog (Flight Reservation Application) and Perform One to One Comparison and Exact match Dim ObjExcel,ObjWorkbook,ObjWorksheet Dim oButton,Buttons,myButton,i Set ObjExcel=CreateObject("Excel.Application") Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and SettingsAdministratorDesktopinput.xls") Set ObjWorksheet=ObjWorkbook.Worksheets(2) ObjWorksheet.Cells(1,2)="Buttons" Set oButton=Description.Create oButton("Class Name").value="WinButton" Set Buttons=Dialog("text:=Login").ChildObjects(oButton) For i=0 to Buttons.Count-1 step 1 myButton=Buttons(i).GetRoProperty("text") ObjWorksheet.Cells(i+2, 2)=myButton www.gcreddy.com 9
  • 10. www.gcreddy.com Next rows_Count= ObjWorksheet.usedrange.rows.count For j= 2 to rows_Count step 1 Expected=ObjWorksheet.Cells(j, 1) Actual=ObjWorksheet.Cells(j, 2) If Expected=Actual Then ObjWorksheet.Cells(j, 3)="Pass" Else ObjWorksheet.Cells(j, 3)="Fail" End If Next ObjWorkbook.Save ObjExcel.Quit Set ObjWorksheet=Nothing Set ObjWorkbook=Nothing Set ObjExcel=Nothing 11) One to One Textual Comparison ------------------------------ 'Capture Button names from Login Dialog (Flight Reservation Application) and Perform and Perform One to One Textual Comparison Dim ObjExcel,ObjWorkbook,ObjWorksheet Dim oButton,Buttons,myButton,i Set ObjExcel=CreateObject("Excel.Application") Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and SettingsAdministratorDesktopinput.xls") Set ObjWorksheet=ObjWorkbook.Worksheets(2) ObjWorksheet.Cells(1,2)="Buttons" Set oButton=Description.Create oButton("Class Name").value="WinButton" Set Buttons=Dialog("text:=Login").ChildObjects(oButton) For i=0 to Buttons.Count-1 step 1 myButton=Buttons(i).GetRoProperty("text") ObjWorksheet.Cells(i+2, 2)=myButton Next rows_Count= ObjWorksheet.usedrange.rows.count For j= 2 to rows_Count step 1 www.gcreddy.com 10
  • 11. www.gcreddy.com Expected=ObjWorksheet.Cells(j, 1) Actual=ObjWorksheet.Cells(j, 2) If StrComp (Expected,Actual,1)=0 Then ObjWorksheet.Cells(j, 3)="Pass" Else ObjWorksheet.Cells(j, 3)="Fail" End If Next ObjWorkbook.Save ObjExcel.Quit Set ObjWorksheet=Nothing Set ObjWorkbook=Nothing Set ObjExcel=Nothing -------------------------------------------------------------------------- 12) Many to Many Comparison ----------------------------------- 'Capture Button names from Login Dialog (Flight Reservation Application) and Perform and Perform Many to Many Comparison Dim ObjExcel,ObjWorkbook,ObjWorksheet Dim oButton,Buttons,myButton,i Set ObjExcel=CreateObject("Excel.Application") Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and SettingsAdministratorDesktopinput.xls") Set ObjWorksheet=ObjWorkbook.Worksheets(2) ObjWorksheet.Cells(1,2)="Buttons" Set oButton=Description.Create oButton("Class Name").value="WinButton" Set Buttons=Dialog("text:=Login").ChildObjects(oButton) For i=0 to Buttons.Count-1 step 1 myButton=Buttons(i).GetRoProperty("text") ObjWorksheet.Cells(i+2, 2)=myButton Next rows_Count= ObjWorksheet.usedrange.rows.count For j= 2 to rows_Count step 1 Expected=ObjWorksheet.Cells(j, 1) www.gcreddy.com 11
  • 12. www.gcreddy.com For k=2 to rows_Count step 1 Actual=ObjWorksheet.Cells(k, 2) If Expected=Actual Then Flag =1 Exit for else Flag= 0 End If next If Flag=1 Then ObjWorksheet.Cells(j, 3)="Pass" Else ObjWorksheet.Cells(j, 3)="Fail" End If Next ObjWorkbook.Save ObjExcel.Quit Set ObjWorksheet=Nothing Set ObjWorkbook=Nothing Set ObjExcel=Nothing ------------------------------------------------------------------- 13) Many to Many Textual Comparison 'Capture Button names from Login Dialog (Flight Reservation Application) and Perform and Perform Many to Many Textual Comparison ----------------------------------- 'Capture Button names from Google home page and export to Excel file 3rd sheet Dim ObjExcel,ObjWorkbook,ObjWorksheet Dim oButton,Buttons,myButton,i Set ObjExcel=CreateObject("Excel.Application") Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and SettingsAdministratorDesktopinput.xls") Set ObjWorksheet=ObjWorkbook.Worksheets(2) ObjWorksheet.Cells(1,2)="Buttons" www.gcreddy.com 12
  • 13. www.gcreddy.com Set oButton=Description.Create oButton("Class Name").value="WinButton" Set Buttons=Dialog("text:=Login").ChildObjects(oButton) For i=0 to Buttons.Count-1 step 1 myButton=Buttons(i).GetRoProperty("text") ObjWorksheet.Cells(i+2, 2)=myButton Next rows_Count= ObjWorksheet.usedrange.rows.count For j= 2 to rows_Count step 1 Expected=ObjWorksheet.Cells(j, 1) For k=2 to rows_Count step 1 Actual=ObjWorksheet.Cells(k, 2) If StrComp (Expected,Actual,1)= 0 Then Flag =1 Exit for else Flag= 0 End If next If Flag=1 Then ObjWorksheet.Cells(j, 3)="Pass" Else ObjWorksheet.Cells(j, 3)="Fail" End If Next ObjWorkbook.Save ObjExcel.Quit Set ObjWorksheet=Nothing Set ObjWorkbook=Nothing Set ObjExcel=Nothing ---------------------------------------------------------------------------------- ----- 14) 'Create Excel file and Rename 1st sheet as "Module", 2nd Sheet as "Test Case", 'and 3rd Sheet as "Test Step" Dim objExcel Set objExcel=CreateObject("Excel.Application") www.gcreddy.com 13
  • 14. www.gcreddy.com objExcel.Visible=True objExcel.Workbooks.Add objExcel.Worksheets("Sheet1").Name="Module" Wait 4 objExcel.Worksheets("Sheet2").Name="TestCase" Wait 4 objExcel.Worksheets("Sheet3").Name="TestStep" objExcel.ActiveWorkbook.SaveAs "C:Documents and SettingsAdministratorDesktopabcd.xls" objExcel.Quit Set objExcel=Nothing ------------------------------------------------------------------------- 15) 'Create an Excel file and add one more Dim objExcel Set objExcel=CreateObject("Excel.Application") objExcel.Visible=True objExcel.Workbooks.Add 'Creating Work Book objExcel.Worksheets.Add 'Creating Work Sheet Wait 4 objExcel.ActiveWorkbook.SaveAs "C:Documents and SettingsAdministratorDesktopabcde.xls" objExcel.Quit Set objExcel=Nothing ---------------------------------------------------------------------------------- ---- 15) 'Capture Button names from Login Dialog (Flight Reservation Application) and perform Many to Many Complete Comparison Capture Button names from Google home page and export to Excel file 3rd sheet Dim ObjExcel,ObjWorkbook,ObjWorksheet Dim oButton,Buttons,myButton,i Set ObjExcel=CreateObject("Excel.Application") Set ObjWorkbook=ObjExcel.Workbooks.Open("C:Documents and SettingsAdministratorDesktopinput.xls") Set ObjWorksheet=ObjWorkbook.Worksheets(2) ObjWorksheet.Cells(1,2)="Buttons" www.gcreddy.com 14
  • 15. www.gcreddy.com Set oButton=Description.Create oButton("Class Name").value="WinButton" Set Buttons=Dialog("text:=Login").ChildObjects(oButton) For i=0 to Buttons.Count-1 step 1 myButton=Buttons(i).GetRoProperty("text") ObjWorksheet.Cells(i+2, 2)=myButton Next rows_Count= ObjWorksheet.usedrange.rows.count x =0 For j= 2 to rows_Count step 1 Expected=ObjWorksheet.Cells(j, 1) flag = 0 For k=2 to rows_Count step 1 Actual=ObjWorksheet.Cells(k, 2) If StrComp (Expected,Actual,1)= 0 Then Flag =1 End If x=x+1 ' increment the comparison count next If Flag=1 Then ObjWorksheet.Cells(j, 3)="Pass" Else ObjWorksheet.Cells(j, 3)="Fail" End If msgbox x 'inner loop comparison values Next msgbox x ' Total number of comparisons ObjWorkbook.Save ObjExcel.Quit Set ObjWorksheet=Nothing Set ObjWorkbook=Nothing Set ObjExcel=Nothing www.gcreddy.com 15