Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading and writing is the same text file
#1
Hi

I want to read the data from a text file and write the result for that data set in the text file at the same time how can i do that in QTP

File Format:-
DATE##FLYFROM##FLYTO##NAME##TICKET##Result
073014##Denver##Paris##Test1##1
072514##Paris##Denver##Test2##2

I want to write the result (pass/fail) under the RESULT col.

Code:-
Code:
systemutil.run"C:\Program Files (x86)\HP\Unified Functional Testing\samples\flight\app\flight4a.exe" Dialog("Login").WinEdit("Agent Name:").Set "mercury" Dialog("Login").WinEdit("Password:").SetSecure "53ba23c99f935b004bba9a2ac1279aec43b6e7d8" Dialog("Login").WinButton("OK").Click Set FSO = createobject("scripting.fileSystemObject") 'FSO.CreateFolder("D:\Poulomi\Test1") 'FSO.CreateTextFile("D:\Poulomi\Sample1.txt") 'set Ofile1= FSO.OpenTextFile("D:\Poulomi\Sample2.txt",2) Set Ofile = FSO.OpenTextFile("D:\Poulomi\Sample2.txt",1) 'Ofile.Write"HELLO" Ofile.SkipLine While Ofile.AtEndOfStream <> true resobj = Ofile.readline ' msgbox resobj arrobj = split(resobj,"##") dtdate = arrobj(0) flyfrom = arrobj(1) flyto = arrobj(2) name = arrobj(3) txt = arrobj(4) ' msgbox dtdate ' msgbox flyfrom ' msgbox flyto ' msgbox name ' msgbox txt 'Ofile1.Write"##" Window("Flight Reservation").ActiveX("MaskEdBox").Type dtdate Window("Flight Reservation").WinComboBox("Fly From:").Select flyfrom Window("Flight Reservation").WinComboBox("Fly To:").Select flyto Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").WinEdit("Name:").Set name Window("Flight Reservation").WinButton("Insert Order").Click Window("Flight Reservation").Dialog("Flight Reservations").WinButton("OK").Click Window("Flight Reservation").WinMenu("Menu").Select "File;New Order" Wend Ofile.Close Set Ofile=nothing Set FSO=nothing

Can someone please help me with this
Reply
#2
Code:
systemutil.run"C:\Program Files (x86)\HP\Unified Functional Testing\samples\flight\app\flight4a.exe" Dialog("Login").WinEdit("Agent Name:").Set "mercury" Dialog("Login").WinEdit("Password:").SetSecure "53ba23c99f935b004bba9a2ac1279aec43b6e7d8" Dialog("Login").WinButton("OK").Click Set FSO = createobject("scripting.fileSystemObject") 'FSO.CreateFolder("D:\Poulomi\Test1") 'FSO.CreateTextFile("D:\Poulomi\Sample1.txt") 'set Ofile1= FSO.OpenTextFile("D:\Poulomi\Sample2.txt",2) Set Ofile = FSO.OpenTextFile("D:\Sample2.txt",1) 'Ofile.Write"HELLO" Ofile.SkipLine While Ofile.AtEndOfStream <> true resobj = Ofile.readline ' msgbox resobj arrobj = split(resobj,"##") dtdate = arrobj(0) flyfrom = arrobj(1) flyto = arrobj(2) name = arrobj(3) txt = arrobj(4) ' 'msgbox dtdate 'msgbox flyfrom 'msgbox flyto 'msgbox name 'msgbox txt 'Ofile1.Write"##" 'Window("Flight Reservation").ActiveX("MaskEdBox").Type dtdate Window("Flight Reservation").WinObject("Date of Flight:").Type dtdate Window("Flight Reservation").WinComboBox("Fly From:").Select flyfrom Window("Flight Reservation").WinComboBox("Fly To:").Select flyto Window("Flight Reservation").WinButton("FLIGHT").Click Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click Window("Flight Reservation").WinEdit("Name:").Set name Window("Flight Reservation").WinButton("Insert Order").Click If(Window("Flight Reservation").WinObject("Insert Done").GetVisibleText = "Insert Done...") Then MsgBox "Pass" Else MsgBox "Fail" End if Window("Flight Reservation").WinButton("Button").Click Wend Ofile.Close Set Ofile=nothing Set FSO=nothing


Check out this code.
Reply
#3
Thanks for the reply but I want to write the result in the same file from where I am reading. I think your code is writing the output in the msgbox.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading Global Sheet's DataTable Value Bhuvana 0 2,073 01-05-2020, 10:03 PM
Last Post: Bhuvana
  Reading Value from Java Table arjun.singh 8 25,832 10-11-2017, 02:51 PM
Last Post: sivaji
  Reading data from excel sheet serenediva 1 10,486 03-03-2017, 10:07 AM
Last Post: vinod123
  QTP not reading all properties ishan.mahajan@adp.com 2 2,942 05-04-2016, 10:50 PM
Last Post: supputuri
  Need to Validate Text filed is blank after clicking on the Text box balak89 3 5,919 09-13-2015, 12:06 AM
Last Post: ADITI1992

Forum Jump:


Users browsing this thread: 1 Guest(s)