Micro Focus QTP (UFT) Forums
Reading a file content which created by QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Reading a file content which created by QTP (/Thread-Reading-a-file-content-which-created-by-QTP)



Reading a file content which created by QTP - Rajashekar Gouda - 03-16-2009

Hi All,

I am facing one issue regarding reading a file, Can any one pls explain me to resolve the issue.

In my test I m copying some text from application, creating a file by command
Code:
"Set f1=fso.CreateTextFile("C:\test10.txt",ForWriting,True)"
and writing that captured text in that file "f1.write(stroutput)".

But Now I want read that file
Code:
Set f2 = fso.OpenTextFile("C:\test10.txt",ForReading,True)
msgbox f2.ReadAll

When I used above two statements i m getting a junk value as "ybT"
(Please see that attached snap for complete script and message box.)

Can I know is that any command to read the file content properly and avoid such junk messages.

Regards
Raj


RE: Reading a file content which created by QTP - Rajashekar Gouda - 03-17-2009

Any update on this?
Regards
Raj


RE: Reading a file content which created by QTP - sreekanth chilam - 03-18-2009

Hi Rajashekar,

Just check with the below way :

Initallt add the browser,page,Webedit objects (Google Page) into OR properly.

Here i have used Opentextfile method(anyhow this method will creates the textfile implicitly)

Add the below code & execute .......

Code:
Dim fso,f,f1
Const ForReading = 1, ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, true)
Stroutput=browser("Google").Page("Google").WebEdit("q").GetROProperty("Value")
f.write(Stroutput)

set f1 = fso.OpenTextFile("c:\testfile.txt", ForReading,true)
msgbox f1.ReadAll


the above code is working fine.Smile


_____________________________________________________________