Tuesday, November 27, 2018

Test Complete- Search data in csv or text file

public function searchdatainfilr()
strfilepath="c:\test. csv
set objfso=createobject(" scripting. filesystemobject")
set infile=objfso. opentextfile("strfilepath")
set outpath=objfso. opentextfile(strfilepath & ". tmp", 2,true)
dim irowcnt
irowcnt=0

do while not infile. atendofstream
line=inline. readline
fullfile=fullfile & line
loop

log. message fullfile
if instr(fullfile, "searctxtval") >0  then
     log. message "validation pass"
else
    log. message "validation fail"
end if
infile. close
outfile. close
objfso. deletefile(strfilepath l
objfso. movefile strfilepath & ". tmp", strfilepath

end function

Tuesday, November 20, 2018

Test Complete- Move file from source to destination

function fnMovefile(Sourcepath, destinationpath)
'path given till folder level only
' code to find csv file from particular location
set foundfiles=aqfilesystem. findfiles(sourcepath, "*.csv")
if not foundfiles is nothing then
    while foundfiles. hasnext
        set afile=foundfiles. next
        var_foundfiles=afile. name
    wend
else
     log. message "no files were found"
end if
call aqfilesystem. copyfile(soyrcepath, deatinationpath)
nowtime=aqdatetime. time()
nowtime=aqstring(nowtime, ":", "_")
nowtime=aqstring(nowtime, "pm", "_")
nowtoday=aqdatetime. today()
nowtoday=aqconvert. vartostr(nowtoday)
nowtoday=aqstring.replace(nowtoday,"/","_")
destinationfile=destinationpath & "\" & varfoundfiles
destinationfilerename=destinationpath & "\" & nowtine & "_" & nowtoday & "_" & varfoundfiles
call aqfile. rename(destinationfike, desti ationfilerename)
log. message " move file with rename successfully"
end function

Test Complete - Find value is present in excel sheet or not

function searchdatainexcel(strpath, searchcol, searchval)
path="c:abc. xls"
set searchdata=DDT. exceldriver(strpath, "sheet1", true)
do while not searchdata. EOF
   if aqconvert. vartostr(searchdata. value(searchcol)) =searchvalue then
       blnflag=true
       exit do
   else
       blnflag =false
   end if
searchdata. next
loop
if blnflag =true then
    log. message "record match"
else
   log. message "record not match"
end if
end function