Professional Documents
Culture Documents
Many a times you may need to interact with text files using QTP. Interaction can
be(but not limited to) in the form of reading input from a file, writing output to a file.
This post describe in detail "File handling using QTP".
What is FSO?
FSO stands for File System Object. This is used to support text file creation and
manipulation through the TextStream object and is contained in the Scripting type
library (Scrrun.dll)
The FSO Object Model has a rich set of properties, methods and events to process
folders and files.
We first create a FSO object using CreateObject and then create a text file using
CreateTextFile.
For Example: Suppose you want to create a file called "test.txt" located in C:
You can use Write() or WriteLine() Methods to write text into a file. The difference
between the Write() and WriteLine() Method is that the latter automatically inserts a
new line character while the former doesn’t insert a new line character.
For example:
Set file= fso.OpenTextFile("C:\file_location", ForWriting, True) //2nd argument should
always be "ForWriting" in order to write contents to a file
file.Write("This is a place to get all your qtp")
file.Write("questions and answers solved.")
//Output will be:
This is a place to get all your qtp questions and answers solved.
while
file.WriteLine("This is a place to get all your qtp")
file.Write("questions and answers solved.")
//Output will be:
This is a place to get all your qtp
questions and answers solved.