Professional Documents
Culture Documents
Examples:
i) Create a Folder
Dim objFso
Set objFso=CreateObject(?scripting.FileSystemObject?)
ii) Check if the Folder Exist or not? If not create the Folder
Set objFso=CreateObject(?scripting.FileSystemObject?)
objFso.CreateFolder (myFolder)
End If
Set objFso=CreateObject(?scripting.FileSystemObject?)
objFso.CopyFolder myFolder,?E:abcd?
Set objFso=CreateObject(?scripting.FileSystemObject?)
objFso.DeleteFolder( myFolder)
2nd
Dim objFso, myFolder
Set objFso=CreateObject(?scripting.FileSystemObject?)
If objFso.FolderExists(myFolder) Then
objFso.DeleteFolder( myFolder)
End If
Set objFso=CreateObject(?scripting.FileSystemObject?)
Set colDrives=objFso.Drives
Msgbox oDrive
Next
Dim objFso
Set objFso=CreateObject(?scripting.FileSystemObject?)
Set myDrive=objFso.GetDrive(?D:?)
Dim objFso
Set objFso=CreateObject(?scripting.FileSystemObject?)
viii) Check if the File Exist or not? If not create the File
Set objFso=CreateObject(?scripting.FileSystemObject?)
objFso.CreateTextFile (myFile1)
End If
objFso.CreateTextFile (myFile2)
End If
objFso.CreateTextFile (myFile3)
End If
objFso.CreateTextFile (myFile4)
End If
Set objFso=CreateObject(?scripting.FileSystemObject?)
Do Until myFile.AtEndOfStream=True
myChar=myFile.Read(1)
Msgbox myChar
Loop
myFile.Close
Set objFso=Nothing
Set objFso=CreateObject(?scripting.FileSystemObject?)
Do Until myFile.AtEndOfStream=True
myChar=myFile.ReadLine
Msgbox myChar
Loop
myFile.Close
Set objFso=Nothing
xi) Data Driven Testing by fetching Test data directly from a Text file.
?
*********************************************************************
****************
?Test Requirement: Data Driven Testing by fetching Test data directly from a Text
file.
?Author: xyz
?Pre-requasites:
?Test Flow:
?Create File System object
?Open the file with Read mode and store reference into a variable
?Login Operation
?
*********************************************************************
****************
Set objFso=CreateObject(?scripting.FileSystemObject?)
myFile.SkipLine
myLine=myFile.ReadLine
myField=Split(myLine,?,?)
Dialog(?text:=Login?).Activate
Wait 2
Dialog(?text:=Login?).WinButton(?text:=OK?).Click
Window(?text:=Flight Reservation?).Close
Loop
myFile.Close
Set objFso=Nothing
a=10: b=20
Result=a+b
Set objFso=CreateObject(?scripting.FileSystemObject?)
myFile.Close
Set objFso=Nothing
Dim objFso
Set objFso=CreateObject(?scripting.FileSystemObject?)
Set objFso=Nothing
xiv) Check if the File Exists or not? If Exists delete the File
????
Dim objFso
Set objFso=CreateObject(?scripting.FileSystemObject?)
End If
Set objFso=Nothing
Dim objFso
Set objFso=CreateObject(?scripting.FileSystemObject?)
Set objFso=Nothing
Option Explicit
Set objFso=CreateObject(?scripting.FileSystemObject?)
Else
End If
Set File_First=objFso.OpenTextFile(File1)
Set File_Second=objFso.OpenTextFile(File2)
myFile1=File_First.ReadAll
myFile2=File_Second.ReadAll
?Msgbox myFile1
End If
Else
End If
Set objFso=Nothing
Option Explicit
Set objFso=CreateObject(?scripting.FileSystemObject?)
Set myFile=objFso.OpenTextFile(File1)
myData=myFile.ReadAll
myWord=?QTP?
Set objFso=Nothing
xviii) Capture all Button Names from Login dialog Box and Export to a Text
File
Option Explicit
Set objFso=CreateObject(?scripting.FileSystemObject?)
Set myFile=objFso.OpenTextFile(FilePath,2)
myFile.WriteLine ??????
Set oButton=Description.Create
oButton(?micclass?).value=?WinButton?
Set Buttons=Dialog(?text:=Login?).ChildObjects(oButton)
TotButtons=Buttons.Count
myButton=Buttons(i).GetRoProperty(?text?)
myFile.WriteLine myButton
Next
myFile.Close
Set objFso=Nothing
*****************************************************************
?Test Requirement: Capture Customer names from 1 to 10 orders
?Test Flow:
?Open the text file in write mode using File sytem object
?Login Operation
?*****************************************************************
Set objFso=CreateObject(?scripting.FilesystemObject?)
myFile.WriteLine ?????
Dialog(?Login?).Activate
Dialog(?Login?).WinEdit(?Password:?).SetSecure ?
4c9e05a626f9b6471971fb15474e791b28cc1ed0?
Dialog(?Login?).WinButton(?OK?).Click
End If
Window(?Flight Reservation?).Activate
Window(?Flight Reservation?).WinButton(?Button?).Click
wait 2
myFile.WriteLine Customer_Name
Next
myFile.Close
Set objFso=Nothing