How do u retrieve data from a text file into different
variables. i.e.
in a text file named "source" , the data is like :
india,1000,japan,200,china,50,singapore,45050
this is given in the first line of the text file.
in the second line of the text file the dta is:
sun,moon,planet,river,earth,water
if u use "readline" method by using FSO concept u can
retrieve the entire line in to a variable. but i want to
import each field (ex: "india" in one variable, "1000" in
another variable etc..). Apprecitae proper replies.
Answer Posted / rajaputra
Hi i got the solution for you.Here it is...
Just go through it, and copy and paste in QTP and run.
You will get it.
'''''''''''Importing Data From Flat File using split''''''
''Source.txt file is having following data
''Arunsingh,40000,KiranKumar,35000,Chandra,50000,Rajesh,20000
''Test Engineer,Developer,Project Leader,HR Executive
Set fso=createobject("scripting.filesystemobject")
Set z=fso.opentextfile("c:\source.txt",1)
l=1
While not z.atendofline
i=1
k=1
count=1
parname=inputbox("Enter Name of The Parameter "&l)
'''''Enter the requiered parameter names
datatable.GetSheet(1).addparameter parname,""
n=z.readline
a=split(n,",")
For j=lbound(a) to ubound(a)
If isnumeric(a(j)) Then
If count=1 Then
datatable.GetSheet(1).addparameter
"Salary",""
count=count+1
end if
datatable.SetCurrentRow(k)
m=l +1
datatable(m,1)=a(j)
k=k+1
else
datatable.SetCurrentRow(i)
datatable(l,1)=a(j)
i=i+1
end if
Next
l=m
l=l+1
Wend
If you have any doubts please contact me at
r.arunsingh@gmail.com
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Hi any body pls help me for QTP 11.0 software free demo version. i have to practice. Kindly send the link.or where i have to download.
How to record a qtp script ?
Suggest and Define a solution for an application whose objects are not recognized by UFT?
How do I generate Test Results window using descriptive method ( run time ) after my test execution process? Please have a look of my below code. ========================================================= Dim qtApp Dim qtTest Dim qtResultsOpt Set qtApp = CreateObject("QuickTest.Application") qtApp.Launch qtApp.Visible = True qtApp.Options.Run.CaptureForTestResults = "Always" qtApp.Options.Run.RunMode = "Fast" qtApp.Options.Run.ViewResults = True qtApp.Open "C:\Automation\Example", True Set qtTest = qtApp.Test qtTest.Settings.Run.OnError = "NextStep" Set qtResultsOpt = CreateObject ("QuickTest.RunResultsOptions") qtResultsOpt.ResultsLocation = "C:\Automation\Example\Res1" qtTest.Run qtResultsOpt MsgBox qtTest.LastRunResults.Status qtTest.Close Set qtResultsOpt = Nothing Set qtTest = Nothing Set qtApp = Nothing ========================================================== This code is working fine, but Test Result window is not displaying after execution. Anybody can please help me regading the same. Thanks Akshaya Madali Capgemini India Pvt Ltd 9823213538
What are the major/ important methods, functions in QTP we use realtime testing
tell me QTP standards ?plz
How to handle dynamic objects in quicktest professional (qtp)?
Can anyone pls tell me in realtime (descriptive programming) how will the properties of the object be given to the test team. R they given in an excel sheet and is the same sheet also given to the development team and by whom is this given? Thanks a lot.
can anyone tell me what to say in interview when interviewer asks about "tell me about your framework in your project"?
can u explain the keyword driven framework with an example clearly how to create all the files and how to attach to main test.
In Test Directory, What are the contents in test case designing? if you prepare in excel sheet how u use thrw Test Directory?
What is keyword view?
I want to configure the OR and library files to a particular QTP test during run time. Note: OR and Library files are located in Quality Center. Is it possible in QTP? Anybody having code?
How can I find out the cursor position through QTP suppose I am keep tabbing(Pressing the tab key continuously) and stoped at a position Now I want to find out where the cursor position is
How you can decide which type of object repository you have to use?