Posts

Showing posts from February, 2017

How to read text file using UFT

We access the text file in UFT by using the filesystemobject. The UFT will read all the data line by line. Below is the sample code which can be used to read any text file. Set  FileSysObj= CreateObject ( "Scripting.FileSystemObject" ) Const  ForReading =  1 Set  txtFile = FileSysObj.OpenTextFile( "<textfile> " , ForReading,  True ) Do  Until  inputFile.AtEndOfStream    msgbox  inputFile.ReadLine   msgbox  inputFile.Line Loop inputFile.close You can use any conditional statement in the code which can be used to extract the required data from the text file.

How to access Excel as a database using UFT

Whenever we access excel through UFT, we always use the createobject method which blocks the excel and starts excel.exe process. It can result in problems if the test script stops abruptly. To resolve this issue you can access the excel as a database through UFT. Below code will help you with that.         Dim oConn, oRS, arrData, x,iStart         CONST adOpenStatic = 3         CONST adLockOptimistic = 3         CONST adCmdText = "&H0001"         Set oConn = CreateObject("ADODB.Connection")         Set objRecSet= CreateObject("ADODB.RecordSet")          'Open Connection         oConn.Open "Provid...