Académique Documents
Professionnel Documents
Culture Documents
www.ramupalanki.com
QTP and File Handling
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.
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
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:
file_location = "C:\file_location"
We would use the same example for the rest of this post.
How to open a file?
//3rd argument is "True" if new file has to be created if the specified file doesn’t exist else false,
blank signify false.
For example:
data = file.ReadLine()
msgbox data
Loop
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:
This is a place to get all your qtp questions and answers solved. while
file_location = "C:\file_location"