Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Editing a notepad file in QTP
#3
Solved: 11 Years, 2 Months ago
Here is a Script I built to Read a file in and search for version Numbers this should give you an idea of how to search for a string in a file.

Code:
ExpectedVersion = Parameter("ExpectedVersion")
TDMRPT_File = Parameter("File_Path")
Record_Found = 0 ' initialize the "Record_Found" flag...

Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile(TDMRPT_File)

Do while MyFile.AtEndofStream <> True
currentLine = MyFile.ReadLine
find_report_record = instr(1,currentLine,"VERSION",1)
Record_Found= Record_Found +find_report_record
If   find_report_record > 0 Then
    MyVersion = Trim(mid(currentLine,2,50))
        If  MyVersion <> " " Then
            splitstring=split(MyVersion,":")
            VersionNumber=replace(splitstring(1)," ","")
            Reporter.ReportEvent micPass, "Version Number Exist", "The Version Number was displayed in "&TDMRPT_File&" File "
            Valid_Version_Number ExpectedVersion, VersionNumber
        Else
        Reporter.ReportEvent micFail, "Version Number Exist", "The Version Number was NOT displayed in "&TDMRPT_File&" File "
        End If
End If
Loop ' AtEndOfStream

If  Record_Found = 0  Then
Reporter.ReportEvent micFail, "Version Number Exist", "The Version Number was NOT displayed in "&TDMRPT_File&" File "
End If
Reply


Messages In This Thread
Editing a notepad file in QTP - by arjun.singh - 03-23-2009, 03:35 PM
RE: Editing a notepad file in QTP - by Jackomcnabb - 03-24-2009, 08:35 PM
RE: Editing a notepad file in QTP - by Ankesh - 10-20-2011, 05:59 PM
RE: Editing a notepad file in QTP - by rajpes - 10-20-2011, 06:31 PM
RE: Editing a notepad file in QTP - by Ankesh - 10-20-2011, 06:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Fifth word from every thousand line in notepad files. sallu.iet@gmail.com 0 904 01-17-2020, 09:58 AM
Last Post: sallu.iet@gmail.com
  QTP 11 Evaluation installation file not having executable file Akhila 2 4,242 10-19-2012, 12:04 AM
Last Post: gdp9600
  Script Editing Problem neerdeth 4 3,469 07-20-2012, 10:12 AM
Last Post: Shridevi.Salagare
  Copy Data from Notepad jegansurya 3 6,589 07-04-2012, 05:31 PM
Last Post: Shridevi.Salagare
  Cannot find the "Edit" object's parent "Notepad" gnanajyothi 1 3,109 04-09-2012, 11:12 AM
Last Post: sshukla12

Forum Jump:


Users browsing this thread: 5 Guest(s)