Você está na página 1de 4

1.

Create an Excel file using the Excel Object

Dim ObjExcel Set objExcel=CreateObject("Excel.application") objExcel.Visible=True objExcel.Workbooks.Add objExcel.ActiveWorkbook.SaveAs "C:\Users\sairam\Desktop\TestData\Excel\Naagexcel_"&second(now)&".xls" objExcel.Quit Set objExcel=nothing

2.Create an Excel file using the Excel Object and Enter some data Dim ObjExcel Set objExcel=CreateObject("Excel.application") objExcel.Visible=True objExcel.Workbooks.Add objExcel.Cells(1,1).value="QTP" objExcel.Cells(1,1).font.size=15 objExcel.ActiveWorkbook.SaveAs "C:\Users\sairam\Desktop\TestData\Excel\Naagexcel_"&second(now)&".xls" objExcel.Quit Set objExcel=nothing

3.Check if the file is exist or not, if exists enter some data, if not create the file and enter some data Dim ObjExcel,objFso Set objFso=CreateObject ("Scripting.FileSystemObject") Set objExcel=CreateObject("Excel.application") filePath="C:\Users\sairam\Desktop\TestData\Excel\Naagexcel.xls" If not objFso.FileExists (filePath) then objExcel.Visible=True objExcel.Workbooks.Add objExcel.Cells(1,1).value="QTP" objExcel.Cells(1,1).font.size=15 objExcel.ActiveWorkbook.SaveAs "C:\Users\sairam\Desktop\TestData\Excel\Naagexcel.xls" Else Set myFile=objExcel.Workbooks.Open(filePath) Set mySheet=myfile.worksheets("Sheet1") mySheet.cells(2,2).value="VBScript" myfile.save End If objExcel.Quit Set objExcel=nothing

4.'Data Driven Testing for Login Operation by fetching test data from an excel file Dim ObjExcel,objFso,mySheet,rc,myFile,filePath Set objFso=CreateObject ("Scripting.FileSystemObject") Set objExcel=CreateObject("Excel.application")

objExcel.Visible=True objExcel.Workbooks.Add objExcel.Cells(1,1).value="AgentName" objExcel.Cells(1,2).value="Pwd" objExcel.Cells(2,1).value="naag11" objExcel.Cells(2,2).value="mercury" objExcel.Cells(3,1).value="naag12" objExcel.Cells(3,2).value="mercury" objExcel.Cells(4,1).value="naag13" objExcel.Cells(4,2).value="mercury" objExcel.ActiveWorkbook.SaveAs "C:\Users\sairam\Desktop\TestData\Excel\Naagexcel.xls" objExcel.Quit filePath="C:\Users\sairam\Desktop\TestData\Excel\Naagexcel.xls" Set myFile=objExcel.Workbooks.Open (filePath) Set mySheet=myFile.Worksheets("Sheet1") rc=mySheet.usedrange.rows.count For i= 2 to rc SystemUtil.run "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.exe" Dialog("Login").WinEdit("Agent Name:").Set mySheet.cells(i,"A") Dialog("Login").WinEdit("Password:").Set mySheet.cells(i,"B") Dialog("Login").Winbutton("OK").Click window("Flight Reservation").Close Next objExcel.Quit Set objExcel=nothing

5.'Data Driven Testing for Login Operation by fetching test data from an excel file and Export Result to the same file

Dim ObjExcel,objFso,mySheet,rc,myFile,filePath Set objFso=CreateObject ("Scripting.FileSystemObject") Set objExcel=CreateObject("Excel.application")

objExcel.Visible=True

objExcel.Workbooks.Add objExcel.Cells(1,1).value="AgentName" objExcel.Cells(1,2).value="Pwd" objExcel.Cells(2,1).value="naag11" objExcel.Cells(2,2).value="mercury" objExcel.Cells(3,1).value="naag12" objExcel.Cells(3,2).value="mercury" objExcel.Cells(4,1).value="naag13" objExcel.Cells(4,2).value="mercury" objExcel.ActiveWorkbook.SaveAs "C:\Users\sairam\Desktop\TestData\Excel\Naagexcel.xls" objExcel.Quit filePath="C:\Users\sairam\Desktop\TestData\Excel\Naagexcel.xls" Set myFile=objExcel.Workbooks.Open (filePath) Set mySheet=myFile.Worksheets("Sheet1") rc=mySheet.usedrange.rows.count msgbox rc For i= 2 to rc SystemUtil.run "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.exe" Dialog("Login").WinEdit("Agent Name:").Set mySheet.cells(i,"A") Dialog("Login").WinEdit("Password:").Set mySheet.cells(i,"B") Dialog("Login").Winbutton("OK").Click If window("Flight Reservation").Exist(5) Then Login="Login Operation sucessfull" mySheet.cells(i,"C")=Login End If window("Flight Reservation").Close Next myFile.Save objExcel.Quit Set objExcel=nothing

6.Create a WorkBook, Rename a Sheet, Add new sheet to WorkBook and Change the Position of Added Sheet Dim objExcel Set objExcel=createObject("Excel.Application") objExcel.Visible=True Set myFile=objExcel.Workbooks.Add

myFile.Sheets("Sheet1").name="QTP" objExcel.Worksheets.Add myFile.Sheets("Sheet4").move myFile.Sheets(4) myFile.SaveAs"C:\Users\sairam\Desktop\TestData\Excel\Naagexcel.xls"

objExcel.Quit Set objExcel=Nothing

7.Script to create a new excel file , write data'''save the file with read and write protected'''''pwd1 is for read protected pwd2 is for write protected 8. Script to open excel file, which is read and write protected write data.'''''pwd1 is for read protected pwd2 is for write protected 9.Script to get the list of links in Google and do spell check 10.Script to check ON the checkboxes in yahoo mail inbox 11.script to select a mail having subject 'hi' or 'HI' 12.Function to send a mail 13.create a new text file 14.read data from a text file 15.create a new excel file and write data 16.open existing file and write data in second column in Sheet1 17.read data from excel from rows and columns 18.get the bgcolor in a cell in excel 19.create word and write data 20.script will display all the doc files in all the drives in the system 21.Open Internet Explorer and navigate to yahoo mail 22.Create word, Create table and write all the services names 23. How To open Password Protected Excel sheets 24.Search for a particular value in Excel 25.Copy an excel sheet to another excel 26.Compare 2 Excel sheets cell by cell 27.Excel Sorting(Ascending , Descending) By Rows and Columns 28.DELETE ROWS FROM XL SHEET 29.DELETE COLUMNS FROM XL SHEET 30.ADODB CONNECTION TO READ DATA FROM EXCEL SHEET 31. Assign Colours to Excel Sheet Cells, Rows 32.Read complete data from an Excel Sheet content 33.Reading complete data from excel file 34.Comapre Two Excel Sheets Cell By Cell for a specific Range 35.Copy an Excel Sheet of one Excel File to another Excel File 36.Add and Delete ExcelSheet 37.Deleting Rows from Excel Sheet 38,Reading Values from a Specific excel Sheet 39.Create excel file and enter some data save it

Você também pode gostar