Showing posts with label UFT. Show all posts
Showing posts with label UFT. Show all posts

Sunday, July 17, 2022

Taking Screenshots in automation

 Some of the scenarios we may need to capture a screenshot using Selenium WebDriver are

i. Application issues
ii. Assertion Failure
iii. Difficulty to find Webelements on the web page
iv. Timeout to find Webelements on the web page

Tosca

Take Screen Shot In Tosca Testsuite

A standard module is provided by tricentis to take screenshot. It is present in standard modules. TBox TakesScreenshot

Selenium

Selenium provides an interface called TakesScreenshot which has a method getScreenShotAs which can be used to take a screenshot of the application under test.

Syntax to capture and save the screenshot.
File screenshotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

Syntax to store it in our local drive

FileUtils.copyFile(screenshotFile, new File("filename_with_path"));

to capture full page screenshot using Selenium WebDriver:

What is aShot?
aShot is a WebDriver Screenshot utility. It takes a screenshot of the WebElement on different platforms (i.e. desktop browsers, iOS Simulator Mobile Safari, Android Emulator Browser).

aShot might be configured to handle browsers with the viewport problem. This gives a screenshot of the entire page even for Chrome, Mobile Safari, etc

Add this jar file in to your project. Note: Select Project and Right click on the Project – Go to ‘Build path’ – Go to ‘Configure build path’ – Click on ‘lib’ section – Add external jar

Screenshot fpScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);

                  ImageIO.write(fpScreenshot.getImage(),"PNG",new File("D:///FullPageScreenshot.png"));

To Capture Screenshot of Failed Test Cases Using Selenium WebDriver

If a script fails, we need to know where was the error in script. Solution for this is to capture a screenshot of webpage when the test case fails. We could easily identify where exactly the script got failed by seeing the screenshot.

To achieve this, we could place the entire code in try-catch block. Which means placing the test steps in try block and screen capture statement in catch block. If a test step fails in the try block then it goes to the catch block and capture a screenshot of the web page.

 

UFT/QTP 

Dim ScreenName

  On Error Resume Next

  ScreenName = " "
  
  CurrentTime = "_Test_Case"&"_"& Day(Now)&"_"& Month(Now)&"_"& Year(Now)&"_"&

   Hour(Now)&"_"& Minute(Now)&"_"& Second(Now)

  ScreenShotName = "Name_of_the_Screen" &  CurrentTime & ".png"

  ScreenName ="Path where the Screenshot needs to be stored"&"\"&ScreenShotName

  Desktop.CaptureBitmap ScreenName,True

 

 

Saturday, August 8, 2020

Find a Filename from folder path

 Public Function fnFindFileFromPath(SearchPath, SearchFileName, dataSht) As String

    Dim StrFile As String

    'Debug.Print "in LoopThroughFiles. SearchPath: ", SearchPath

 '   StrFile = Dir(SearchPath & "\*" & SearchFileName)

    StrFile = Dir("D:\Test\")

     While (StrFile <> "")

      If InStr(StrFile, "Test") > 0 Then

         MsgBox "found " & StrFile

         Exit Function

      End If

     StrFile = Dir

    Wend

End Function

Thursday, June 11, 2020

VBA Function to Clear content except header rows and Get col headers in string or array

Folks,

sometimes need to use only headers or template from existing file then below code might help to clear the data. Sometimes you need to capture the column header in array or string then below function will help you.

Function DeleteExceptFirstHeader(shWrite)
    'shWrite.Rows("2:" & Rows.Count).ClearContents
    shWrite.Rows("2:" & Rows.Count).Clear
End Function

Function fnReadColHeader(wST As Worksheet)
    Dim strData() As Variant
    lastCol = wST.Range("a1").End(xlToRight).Column
    strData = wST.Range("1:" & lastCol).Value
    strHeaders = 0
    Dim columnCounter As Long
 
    For columnCounter = LBound(strData, 1) To UBound(strData, 1)
        strHeaders = strHeaders & ":" & strData(1, columnCounter)
    Next columnCounter
 '   MsgBox strHeaders
   fnReadColHeaderDRF = strHeaders
End Function

Cheers.
TJ

VBA Function to Generate Dummy data for numbers, string and date values

Hi guys,

If you need to generate any random dummy data for string/alphanumeric/date/numbers(2 digit/3 digit) then below logic might help you.

provide your sDatatype in below select case.

  Select Case sDataType
            Case Is = "Alphabets"
                dtRndData = UCase(Cnst) & Vowel & Cnst & Vowel & Cnst
            Case Is = "Alphanumeric"
                DLocation = UCase(Cnst) & Vowel & Cnst & Vowel & Cnst
                dtRndData = Tens() & " " & DLocation
            Case Is = "Date"
                dtRndData = GetRndDate(#12/1/1965#, #5/31/2020#)
            Case Is = "Numbers"
                dtRndData = Tens()
        End Select

Function LName()
    Dim i As Long, Tmp As String
    LName = UCase(Cnst) & Vowel & Cnst & Vowel & Cnst
End Function

Function Vowel()
      Dim V
      V = Array("a", "e", "i", "o", "u")
      Vowel = V(Int((5 * Rnd)))
End Function
   
Function Cnst()
    Dim C
    C = Array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", _
                "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z")
    Cnst = C(Int((21 * Rnd)))
End Function
Function Tens()
    Tens = Int(100 * Rnd)
End Function

Function Hundreds()
    Hundreds = Int(1000 * Rnd)
End Function

Function GetRndDate(dtStartDate As Date, dtEndDate As Date) As Date
    On Error GoTo Error_Handler
    Dim dtTmp                 As Date

    'Swap the dates if dtStartDate is after dtEndDate
    If dtStartDate > dtEndDate Then
        dtTmp = dtStartDate
        dtStartDate = dtEndDate
        dtEndDate = dtTmp
    End If

    Randomize
    GetRndDate = DateAdd("d", Int((DateDiff("d", dtStartDate, dtEndDate) + 1) * Rnd), dtStartDate)

Error_Handler_Exit:
    On Error Resume Next
    Exit Function

Error_Handler:
    MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: GetRndDate" & vbCrLf & _
           "Error Description: " & Err.Description & _
           Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
           , vbOKOnly + vbCritical, "An Error has Occurred!"
    Resume Error_Handler_Exit
End Function

Getting data type from given value whether Number/String/Date/Alphanumeric

Hi Folks,

Sometimes need to generate some random test data based on given value of cell or variables data value, whether it is number, date, string, alphabets.
strOrignalData="John Smith" 'DOB,phone number any original data

 sDataType = GetDatatype(strOrignalData)

Public Function GetDatatype(strData)
            numbers = 0
            alphabets = 0
            specialChar = 0
            For i = 1 To Len(strData)
                b = Mid(strData, i, 1)
                If IsNumeric(b) Then
                 numbers = numbers + 1
                ElseIf (Asc(b) >= 97) And (Asc(b) <= 122) Or Asc(i) >= 65 And Asc(i) <= 90 Then
                 alphabets = alphabets + 1
                ElseIf InStr(b, "/") > 0 Then
                 specialChar = specialChar + 1
                Else
                    'None
                End If
            Next
            If numbers = Len(strData) Then
                strdatatype = "Numbers"
            ElseIf specialChar >= 2 Then
                strdatatype = "Date"
            ElseIf alphabets > 0 And numbers = 0 Then
                strdatatype = "Alphabets"
            Else
                strdatatype = "Alphanumeric"
            End If
            GetDatatype = strdatatype
         
End Function

cheers.
TJ

Generate filename with date time stamp and separate file name and path from given file path

Hi folks,

many times we need to create the dummy or new file or report file with date timestamp appending to file name. Also, from the given file path we need to separate the file name and file path then definitely this post might help you.

Public Function AddResultTestdatafile(strFilePath)
   
    Workbooks.Add Template:=strFilePath
    strNewFileTempName = getFName(strFilePath)
    strTestFileNameval = Split(strNewFileTempName, ".")
    strNewFilePath = getPath(strFilePath)
    'to generate file name appending datetime stamp
    strNewTestFileName = strTestFileNameval(0) & "_" & "DummyData" & "_" & Year(Date) & Right("00" & Month(Date), 2) & Right("00" & Day(Date), 2) & Right("00" & Hour(Time), 2) & Right("00" & Minute(Time), 2) & Right("00" & Second(Time), 2) & ".xlsx"
    ActiveWorkbook.SaveAs _
        Filename:=strNewFilePath & strNewTestFileName
    ResultDummyFilename = strNewFilePath & strNewTestFileName
    AddResultTestdatafile = ResultDummyFilename
   
End Function

'to get the path from given file path
Function getPath(pathfile) As String: getPath = Left(pathfile, InStrRev(pathfile, "\")): End Function

'to get the file name from given file path
Function getFName(pathfile) As String: getFName = Mid(pathfile, InStrRev(pathfile, "\") + 1): End Function

Cheers.
TJ

Wednesday, April 15, 2020

Dictionary Object in UFT or Testcomplete

A Dictionary object contains a set of key-item pairs
The dictionary object has the following benefits when compared with arrays:
·         The size of the Dictionary object can be set dynamically.
·         Dictionaries surpass arrays in locating items by their content.
·         Dictionaries work better than arrays when accessing random elements frequently.
·         The Dictionary object has built-in methods and properties that allow users to manage the dictionary’s contents and keys.
·         When deleting an item from a Dictionary, the remaining items are automatically shifted up.
The only disadvantage of dictionaries when compared to arrays, is that they cannot be multidimensional.
Methods:
  1. Add
  2. Exists
  3. Items
  4. Keys
  5. Remove
  6. Removeall

Properties
  1. Count
  2. Item
  3. Key
  4. Comparemode

Wednesday, December 19, 2018

Test Complete /UFT- Automation of Database

dim objconnection
set objconnection= Createobject("Adodb. co nection)

'function to connect sql server
public function opendbconnection()
aqutils. delay 3000
strcoonectionstring="provoder=sqloledb;datasourcee=strdatasourceval;initial catalog=strcatval;security=sspi;persist security info=true"
objconnection. open strcoonectionstring
if objconnection. state=1  then
   log. message "DB connect"
else
Log. message "Db not connect"
end if
end function

'function to close db connection
public function closedbconnection()
objconnection. close
if objconnection. state <>1  then
   log. message "DB connection close"
else
Log. message "Db not connection not close"
end if

end function

dim strcodedelimiter, strDBrowdelimiter
strdbrowdelimiter="@@"
strcodedelimiter="|"

public function get_db_row()

dim objrecordset, strdbrow
strdbrow=""
if objconnection. state=1 then
    set objrecordset =createobject (adodb. recordset")
    objrecordset. activeconnection=objconnection
   objrecordset. open DBquery, objconnection
   if not objrecordset. eof then
    while not objrecordset. eof
         for intdbcolcounter=0 to objrecordset. fields. count-1  step 1
               strcurrentvalue=objrecordset. fields(intdbcolcounter). value
          if isnull(strcurrentvalue) or strcurrentvalue ="" then
           strcurrentvalue =Null
          end if
strdbrow=strdbrow & strcodedelimiter & strcurrentvalue
next
strdbrow= strdbrow & strdbroedelimiter
objrecordset. movenext
wend
if left(strdbrow, 1)=strcodedelimiter then
    strdbrow =right(strdbrow, len(strdbrow) - 1)
end if
strdbrow =replace(strdbrow, strdbrowdelimiter & strcodedelimiter, strrowdelimiter)
objrecordset. close
set objrecordset =nothing

else
    log. message "no data found"
end if
get_db_row= strdbrow

else
     log. message "db connection fail"
end if

end function

'function to update db row
public function uodate_db_row()
dim objrecordset, strdbrow
strdbrow=""
if objconnection. state=1 then
    set objrecordset =createobject (adodb. recordset")
    objrecordset. activeconnection=objconnection
   objrecordset. open DBquery, objconnection
   if err. description <>"" then
          log. message "no data found in db"
    else
bdbflag=true
end if
else
bdbflag=false
log. message "db connection failed"
end if
update_db_row=bdbflag

end function

'function to compare db value
public function comparedbvalue(strvalidatiinval, strdbvalue)
dim bdbvalflag
if aqutils. vartostr (strvalidatiinval) =aqutils. vartostr (strdbvalue) then
   bdbvalflag=true
else
bdbvalflag=false
end if
comparedbvalue=bdbvalflag
end function

Test Complete / UFT-launch window application

Test Complete
Dbgservices object is only available if dbgservices plugin is installed.
set proc=dbgservices. launchtestedapplication(strapppath)
Res=proc. exists
if Res then
     log. message ("App launch successfully")
else
log. message (" app not started")
end if

UFT
systemutil.run strapppath

Test Complete / UFT-Run functions dynemic through excel files

Hey folks,

sometimes functions execution flow needs to controll through excel files and need to run the functions dynemic, so hope this line of code will help. Same applies to UFT as well.

in excel sheet, for exampme TC1 having FUNC1-10 then,

for fncnt=1 to sheet. columncount
    strfunctionname=""
    if(aqconvert. vartostr(fncnt)) <>"" then
         strfunctionname=aqconvert. vartostr(testcasedriver. value(fncnt))
        functiontorun="Call" & strfunctionname
       execute functiontorun
    end if
next

wishes,
Trupti

Test Complete-Terminate window application or exe using vbscript

dim process, strprocesstokill, strobject, strcomputer

strcomputer="."
strobject="winmgmts://" & strcomputer
'To kill multiple instance like excel or anything use for loop else use without for loop
for each process in getobject(strobject). instanceof("win32_process")
       if (sys. waitprocess(strprocess), 0).exists) then
              sys. process(strprocess). Terminate()
       End if
Next

Tuesday, December 18, 2018

Send Email through vbs using CDO object

set  objemail=createobject("cdo. message")
objemail. from=strmailfrom
objemail. to=strmailto
objemail. subject=strmailsubject
objemail. textbody=strmailbody
strmailattachment="c:\test. btml"
objemail. addattachment strmailattachment
objemail. configuration. fields. item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
objemail. configuration. fields. item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mailhost. ldn... com"
objemail. configuration. fields. item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =25
objemail. configuration. fields. update
objemail. send

Send email through vbs using Outlook Application utility object

set objoutlookmail=createobject("outlook. application")
Set mymail=objoutlookmail. createitem(0)
mymail.display
set mymailproperty=objoutlookmail. activeinsepector
if mymailproperty. iswordmail="trur" then
    set mydoc=mymailproperty. wordeditor
    mydoc. range chr(13)+"Hi All," +chr(13) & " Please see execution status for.... application." +chr(13)
     mydoc.range.insertafter chr(13)+"Regards,"+chr(13) & "support team" +chr(13)
     strmailattachment="c:\test. html"
      mymail. Attachments. add strmailattachment
       mymail. from="abc@gmail.com"
       mymail. to="xyz@gmail.com;pyz@gmail.com"
      mymail. subject="Application Automation Execution Reports"
       mymail. send
end if
Set mymail.=Nothing
Set mydoc=Nothing
Set objoutlookmail=Nothing

Friday, October 5, 2018

Read XML file as string using Vbscript

hi folks, To read XML file as entirely string we can use below logic. Hope it will useful.

set xmldoc=createobject("MICROSOFT. XMLDOM")
xmldoc. async=false
xmldoc. load(recentxmlfilepath)
for each ochdnd in xmldoc. documentelement. childnodes
     strxmldocline=ochdnd. nodename & ":" & ochdnd. text & vbcrlf
xmldocdata= xmldocdata & strxmldocline
next
msgbox xmldocdata

cheers
Trupti

Thursday, August 2, 2018

Text file edit using UFT/QTP/VBS

Hi folks

Create test file on path with content.

Test file edit data-Trupti to Jethva
Data -Trupti

Save file c:\test.txt

Now write function as
Public function fnModifytextfile(strfilepath,strchangedata)
Const ForReading=1
Const ForWriting=2
Set objfso=createobject(“scripting.filesystemobject”)
Set myfile=objfso.opentextfile(strfilepath,forreading,true)
Set mytemp=objfso.opentextfile(strfilepath & “.tmp”, forwriting,true)
Do while not myfile.atendofstream
       Myline=myfile.readline
       If instr(myline,”Data”) then
            Orignaldata=split(myline,”-“)
            Orignaldatachange=orignaldata(1)
            Datatobechange=“ “& strchangedata
            Myline=replace(myline,orignaldatachange,datatobechange)
       Endif
       Mytemp. Writeline myline
Loop
Myfile.close
Mytemp.close
Objfso.deletefile(strfilepath )
Objfso.movefile strfilepath & “.tmp”, strfilepath
Msgbox “done”
End function
Call fnModifytextfile(“c:\test.txt”,”jethva”)

Tuesday, October 31, 2017

Key design activities and component for framework

Folks,

Following are key design activities for create robust automation framework

1. Define standard project folder hierarchy
2. Define standard configuration and launcher script.
3. Design standard format for automation component
4. Define reusable modules to reduce development and maintenance cost
5. Define layered architecture of reusable modules
6. Design standard flow control module
7. Design standard data storage, loading, sharing mechanism
8. Define standard reporting mechanism
9. Design standard error or exception handling mechanism

Components
1. Controller
2. Reusable component
3. Event Handler
4. Reporter

Regards, Trupti 

Read, write and delete a key from windows system registry

Dim owshell, skeypath, Skeyval, skeytype
Skeypath= "hkey_current_user\mycustomekey\mycustomedata\myvalue"
Skeyval="this is UFT made registry"
Skeytype="reg_sz"

Set owshell= createobject("wscript.shell")
Owshell.RegWrite skeypath,Skeyval ,skeytype

Skeyval = owshell .RegRead(skeyPath)
Print Skeyval

Owshell .RegDelete skeypath
 'To run application
SApp="notepad.exe"
Owshell .run sApp
Set owshell = nothing

Monday, October 30, 2017

File Rename, invalid extension and modify file data using UFT

'Invalid file extension
Public Function fnFileInvalidExtn(strfolderSourcePath,strfolderdestnPath,strFile)
   
        Set FSO=CreateObject("Scripting.FileSystemObject")
        strfolderSourcePath_mod=strfolderSourcePath&"\"&strFile
        strTestFileName1=Split (strFile,".")
        strTestFileNameFir=strTestFileName1(0)
        strTestFileName_extn_chg=strTestFileNameFir&"."&"d"
        strfolderdestnPath_mod=strfolderdestnPath&"\"&strTestFileName_extn_chg
        FileEx=FSO.FileExists(strfolderSourcePath_mod)
   
        If FileEx=True Then
            FSO.MoveFile strfolderSourcePath_mod,strfolderdestnPath_mod
            Call fnDoneResult("File Extension changed is Sucessful","File is renamed to " & strfolderdestnPath)    
        else
            Call fnFailResult("File Extension changed is UnSucessful ","Unable to renamed file to " & strfolderdestnPath)
        End If
        fnFileInvalidExtn=strTestFileName_extn_chg
                               
End Function

'File Rename

Public Function fnFileRename(strfolderSourcePath,strfolderdestnPath,strFile)
        Set FSO=CreateObject("Scripting.FileSystemObject")
        strfolderSourcePath_mod=strfolderSourcePath&"\"&strFile
        strTestFileNamemsg=Split (strFile,".")
        strTestFileNameFir=strTestFileNamemsg(0)
        strNewTestFileName=Left(strTestFileNameFir,5)&"_"&"Data"& "_" & year(Date) & Right("00" & Month(Date),2) & Right("00" & Day(Date),2) & Right("00" & Hour(Time),2) & Right("00" & Minute(Time),2)  & Right("00" & Second(Time),2) & ".dat"
        strfolderdestnPath_mod=strfolderdestnPath&"\"&strNewTestFileName
        FileEx=FSO.FileExists(strfolderSourcePath_mod)
   
    If FileEx=True Then  
        FSO.MoveFile strfolderSourcePath_mod,strfolderdestnPath_mod
        Call fnDoneResult("File Rename is Sucessful","File is renamed to " & strfolderdestnPath)    
      else
        Call fnFailResult("File Rename is UnSucessful ","Unable to renamed file to " & strfolderdestnPath)
    End If
fnFileRename=strNewTestFileName  
End Function

'Function to modify the file data
Public Function fnModifyFile(strFilePath,strOrignalString, strmodifiedString)
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFilePath, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, strOrignalString, strmodifiedString)
Set objFile = objFSO.OpenTextFile(strFilePath, ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Function

Cute FTP connect, disconnect and file upload

'function to connect cute FTP
public function fnConnectCuteFTP(strHost,strUploadUserID,strUploadPwd)
Dim Flag
If Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").Exist Then
       Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").Close
    End If
Systemutil.Run "C:\Program Files (x86)\Globalscape\CuteFTP\cuteftppro.exe"
Wait (5)
Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").Dialog("regexpwndclass:=#32770","regexpwndtitle:=Tip of the Day").WinButton("regexpwndclass:=Button","regexpwndtitle:=&Close").Click
Wait(1)
Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").WinEdit("regexpwndclass:=Edit","attached text:=Host:").Type trim(strHost)
Wait(1)
Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").WinEdit("nativeclass:=Edit","attached text:=Username:").Set trim(strUploadUserID)
Wait(1)
Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").WinEdit("nativeclass:=Edit","attached text:=Password:").Set trim(strUploadPwd)
Wait(1)
Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").WinToolbar("regexpwndclass:=ToolbarWindow32","regexpwndtitle:=Quick Connect").Press 1
Wait (5)
If Window("regexpwndclass:=#32770","regexpwndtitle:=File Transfer Log").Exist Then
       Window("regexpwndclass:=#32770","regexpwndtitle:=File Transfer Log").Close
       Call fnFailResult("CuteFTP Connection Failure ","Unable to connect to CuteFTP")
Flag=False      
    Else
       Call fnDoneResult("CuteFTP Connection Sucessful ","CuteFTP connection is sucessful")
Flag=True      
    End If
    fnConnectCuteFTP=Flag
End function

Public function fnDisconnectCuteFTP()
If Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").Exist Then
       Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").Close
Call fnDoneResult("CuteFTP DisConnection","CuteFTP Disconnected sucessful")      
    Else
Call fnFailResult("CuteFTP is not launched","Unable to close as CuteFTP is not launched")  
    End If

End function

Public Function fnCuteFTPFileUpload(strFileSourcePath,strTestFileName)
Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").WinEdit("regexpwndclass:=Edit","window id:=132").Set trim(strFileSourcePath)
Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").WinEdit("regexpwndclass:=Edit","window id:=132").Type micReturn
Count=Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").WinListView("regexpwndclass:=SysListView32","window id:=1200").GetItemsCount
For i = 0 To Count
        FileName=Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").WinListView("regexpwndclass:=SysListView32","window id:=1200").GetItem(i)
        If FileName=trim(strTestFileName) Then
           Window("regexpwndtitle:=Globalscape","regexpwndclass:=Afx:").WinListView("regexpwndclass:=SysListView32","window id:=1200").Activate i
           Exit For
        End If
Next
Call fnDoneResult("CuteFTP Fileupload done","CuteFTP File upload sucessful")
End Function

Validate Environment Variable value

Environment is global object in UFT, it can be used to store and retrieve both run time and design time data.
Two type of environment variables
1. User defined-it has two types
- internal variable-- referred as default values
-external variable-- referred as constant value
2. Built in-give two type of information
- static data such as OS,OS version,local host name, test name, test fir etc
-Runtime data such as test iteration ,action name,action iteration etc

function for Validate_EnvironmentVar
Public function fnVerifyEnvironmentVar(strTestCaseID,strVarName,strVarValue)
Dim Flag
Set Obj = CreateObject("wscript.shell")
set objEnv = Obj.Environment("System")
sVarValue = objEnv.Item(strVarName)
If Trim(ucase(sVarValue))=Trim(ucase(strVarValue)) Then
Call fnDoneResult("Environment variable verify successfully", strVarName & " variable have value " &strVarValue& " match successfully.")
Flag=True
else
Call fnFailResult("Environment variable verify unsuccessfully",strVarName & " variable have value " &strVarValue& " not match successfully.")
Flag=False
End If
fnVerifyEnvironmentVar=Flag

End function