QTP Script for Data Driven Testing using Notepad

5 pts.
Tags:
Data-driven testing
QTP
QTP script error handling
QTP Scripting
QuickTest Professional
Set f=createobject("scripting.filesystemobject") Set f1=f.createtextfile("d://file1.txt") f1.writeline"Raju Rani" f1.writeline"King Queen" f1.writeline"Radha Krishna" f1.writeline"Thirupathi Gangula" f1.writeline"Bala Kishan" The above script creates a notepad in "d" drive with name file1 Raju Rani King Queen Radha Krishna Thirupathi Gangula Bala Kishan values are stored in file1.txt. Set f2=f.opentextfile("d://file1.txt") While f2.atendofstream<>true f3=f2.readline x=split(f3," ") msgbox x(0) msgbox x(1) Wend The above script is used for data driven using notepad directly.here we are not importing data to excel sheet. directly values are retreived from notepad. we are using while loop and reading each line till the end. split function splits the line where space(" ")occurs. line is divided to 2 parts.one before space and other after space for example we have 1st line in notepad as aaa bbb here aaa is 1st part and bbb is 2nd part x(0)=Raju x(1)=Rani all values are read this way using while loop. One point to note here is if any line is empty in notepad datadriven testing is stopped before that line. It will not proceed further.so we have to give values without any empty lines in notepad. to make u more clear suppose u have Raju Rani Knig queen datadriven is stopped at Raju and Rani only because next line is empty.datadriven is stopped after 1st line. Could you please anybody otherthan this method only on Notepad Cheers..........! Thirupathi
ASKED: February 15, 2009  10:42 AM
UPDATED: September 29, 2010  6:55 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Dim fso, f , Readline_file,wordcount,i
i=0
Set fso = Createobject(“Scripting.FileSystemObject”)
‘Set Myfile = fso.OpenTextFile (“g:\new.txt”, ForWriting , True)
‘Set f = fso.CreateTextFile (“g:\new2.txt”, True)
‘f.writeline “world hello”
‘f.writeline “Google 05121974″

Set f = fso.OpenTextFile(“g:\new2.txt”)

do until f.AtEndOfStream = true
Readline_file = f.readline
wordcount = split(Readline_file,” “)
For each i in wordcount
If (i = fine) Then

msgbox “sucess”
End If
‘msgbox Readline_file
Next
Loop
‘Readline_file = f.read (5)’ (“g:\new1.txt”, )
‘Set f = fso.OpenAsTextStream(“g:\new1.txt”)

‘f.Writeline “Enter into the new world”
f.Close

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following