Posts

Showing posts from 2017

An easy way to create Database connection string in UFT

Image
I was also facing a lot of issues while creating the database connection string and remembering all the parameters. And always thought if there is any utility which i can use to create the connection string easily and can test it also without running my code. In UFT we have the microsoft query wizard where we can create the new connection string using the wizard and can save it in a dsn file. Below are the steps: 1. Open the Microsoft query wizard in UFT. Below screenshot will give you the easiest way to open it from UFT: 2. After clicking on "From Database" as shown in above screenshot. Select option "Specify SQL statement Manually" and click on Next. 3. Now click on Create button shown in below screenshot: 4. Now it will take you to create or select Data source. As we are creating a new, so you need to click on New button as shown in below screenshot: 5. After performing above step, select the driver based on the database you want to ...

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...