QTP Forum


Join the forum, it's quick and easy

QTP Forum
QTP Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Poll
Keywords

Latest topics
» composite primary key
Retrieving data from Txt file into datatable EmptyThu Jun 19, 2014 11:31 am by thomasdfg

» How to identify the object when it is dynamically changing behavior
Retrieving data from Txt file into datatable EmptyWed Jun 18, 2014 6:37 pm by thomasdfg

» Patches for QTP 10, 11, 11.5
Retrieving data from Txt file into datatable EmptyWed Jun 18, 2014 6:04 pm by thomasdfg

» Retrieving data from Txt file into datatable
Retrieving data from Txt file into datatable EmptyWed Jun 18, 2014 5:32 pm by thomasdfg

» VB Script to count number of links in a web page.
Retrieving data from Txt file into datatable EmptyWed Jun 18, 2014 4:51 pm by thomasdfg

» Customized HTML reports in QTP
Retrieving data from Txt file into datatable EmptyWed Jun 18, 2014 4:42 pm by thomasdfg

» how to print values into a field of a web page, from a data table in qtp?
Retrieving data from Txt file into datatable EmptyWed Jun 18, 2014 4:37 pm by thomasdfg

» How to delete cookies using QTP?
Retrieving data from Txt file into datatable EmptyWed Jun 18, 2014 4:30 pm by thomasdfg

» When UFT Does Not Identify an Object
Retrieving data from Txt file into datatable EmptyWed Jun 18, 2014 4:23 pm by thomasdfg

April 2024
MonTueWedThuFriSatSun
1234567
891011121314
15161718192021
22232425262728
2930     

Calendar Calendar

Affiliates
free forum


Retrieving data from Txt file into datatable

Go down

Retrieving data from Txt file into datatable Empty Retrieving data from Txt file into datatable

Post by thomasdfg Wed Jun 18, 2014 5:32 pm

Code:
Public Function ReadLineTextFile (strTextFile)
Dim fso, MyFile
Dim arrPairs, arrColumns, i
Set fso = CreateObject("Scripting.FileSystemObject")
  ' Open the file for reading only
  Set MyFile = fso.OpenTextFile(strTextFile, 1)
  ' Read the input file
  ReadLineTextFile = MyFile.ReadLine
  ' Load the Global DataSheet.
  arrPairs = Split(ReadLineTextFile, "|")
  ' Note: This loop begins at Index 3 because Indices 0, 1, and 2
  '      (CurrentURL, CurrentBrowser, and CurrentPage) are already
  '      in the Global DataSheet)
  For i = 3 To UBound(arrPairs) - 1
    arrColumns = Split(arrPairs(i), ";")
    DataTable.GlobalSheet.AddParameter arrColumns(0), ""
    DataTable.Value(arrColumns(0), dtGlobalSheet) = arrColumns(1)
  Next
End Function '  ReadLineTextFile (strTextFile)
In your test script, just identify the path and filename of the text file...
  ' Identify the name of the input file to use.
  strTextFilePath = "C:\Test Data Files\"
  strTextFile = strTextFilePath & "FileName.txt"
Then just call the function when you need to...
  Call ReadLineTextFile (strTextFile)
thomasdfg
thomasdfg

Posts : 11
Join date : 2014-06-18
Age : 39
Location : Hyderabad

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum