what is a file system object in QTP

Questions by vamsi.krishna09

Editorial / Best Answer

chitta10  

  • Member Since Jul-2009 | Mar 29th, 2010


File system object is to create a file where you can store your informations and also read. Have a look to my exemple I think you can understand it.

SystemUtil.Run "iexplore.exe","","C:Documents and Settingsuser18Desktop",""
Browser("Google").Page("Google").Link("Gmail").Click
Browser("Google").Page("Gmail: Email from Google").Sync
Dim x,y
Set x = CreateObject("Scripting.FileSystemObject")
Set y = x.Createtextfile("d:testfile.xls",true)
If Browser("Google").Page("Gmail: Email from Google").Exist Then
y.writeline("step1 login details is pass")
else
y.writeline("step1 login details is fail")
End If
Browser("Google").Close

Thanks and regards,
CHITTA.

Showing Answers 1 - 8 of 8 Answers

smartmanoj

  • Nov 27th, 2006
 

hi vamsi.. very happy to reply to ur question.  File system object is the one which helps u to create ur file stream from which u can read the text file or u can write into. 

  Was this answer useful?  Yes

Nadeem Sharifuddin

  • Dec 19th, 2006
 

File System is used to create file through scripting.

We can read, write and save data in txt file and use it after wards during testing.

Here is example of creating txt file through FSO

   Const ForReading = 1, ForWriting = 2
   Dim fso, MyFile
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.OpenTextFile("c:testfile.txt", ForWriting, True)
   MyFile.WriteLine "Hello world!"
   MyFile.WriteLine "The quick brown fox"
   MyFile.Close
   Set MyFile = fso.OpenTextFile("c:testfile.txt", ForReading)
   ReadLineTextFile = MyFile.ReadLine    ' Returns "Hello world!"

It will create testfile.txt and enter "This is a test" in that text file.

You can later read that line "This is a test" from this file while using

MyFile.ReadLine

We can save variables data during testing and then use that data in future instances of testing and then delete that file.

Nadeem.

aruna

  • Oct 4th, 2007
 

This code works fine, it prints line by line in msgbox

Const ForReading = 1, ForWriting = 2
Dim fso, MyFile,strNextLine
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("h:testfile.txt", ForWriting, True)
MyFile.WriteLine "Hello world!"
MyFile.WriteLine "The quick brown fox"
MyFile.Close
Set MyFile = fso.OpenTextFile("h:testfile.txt", ForReading)

Do Until MyFile.AtEndOfStream
strNextLine=MyFile.Readline
MsgBox strNextLine
Loop

Bye

  Was this answer useful?  Yes

brainwood

  • Feb 13th, 2008
 

Question:

How do we load a text file from QC?

Answer:

strFilePath = PathFinder.Locate("[QualityCenter] SubjectFolderNameAttachmentName.txt")

   Const ForReading = 1, ForWriting = 2
   Dim fso, MyFile
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.OpenTextFile(strFilePath, ForReading)
   ReadLineTextFile = MyFile.ReadLine    ' Returns first line of AttachmentName.txt
   MyFile.Close

  Was this answer useful?  Yes

File system object is to create a file where you can store your informations and also read. Have a look to my exemple I think you can understand it.

SystemUtil.Run "iexplore.exe","","C:Documents and Settingsuser18Desktop",""
Browser("Google").Page("Google").Link("Gmail").Click
Browser("Google").Page("Gmail: Email from Google").Sync
Dim x,y
Set x = CreateObject("Scripting.FileSystemObject")
Set y = x.Createtextfile("d:testfile.xls",true)
If Browser("Google").Page("Gmail: Email from Google").Exist Then
y.writeline("step1 login details is pass")
else
y.writeline("step1 login details is fail")
End If
Browser("Google").Close

Thanks and regards,
CHITTA.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions