This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Detailed Software Testing Tutorials and Interview Questions.

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Detailed Software Testing Tutorials and Interview Questions.3

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Detailed Software Testing Tutorials and Interview Questions.3

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Detailed Software Testing Tutorials and Interview Questions.3

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Detailed Software Testing Tutorials and Interview Questions.3

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Tuesday 18 October 2011

Import a data sheet into your test at runtime.


' =============================================================
' function: ImportDataSheet
' desc : Imports a single data sheet
' params : strFile - full path of the xls file with the sheet
' strSource - name of the sheet on the xls
' strTarget - name of the sheet to import it to
' returns : void
' =============================================================

Function ImportDataSheet(strFile, strSource, strTarget)

 

Dim objFS

 

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

 

' check that the source file exists
If objFS.FileExists(strFile) Then

 

    ' ensure that our target sheet exists
    DataTable.AddSheet strTarget

 

    ' import the sheet
    DataTable.Importsheet strFile, strSource, strTarget

 

Else

 

    ' fail if the xls was not found
    Reporter.ReportEvent micFail, "Import Data Table""Unable to Import Data Table From '" & strFile & "', File Does Not Exist"

 

End If

 

' destroy the object
Set objFS = Nothing

 

End Function 'ImportDataSheet


Export a data sheet at runtime.



' =============================================================
' function: ExportDataSheet
' desc : Exports a data sheet
' params : strFile - full path to save the exported xls, note
' that any existing xls will be deleted
' strSheet - sheet to export
' returns : void
' =============================================================

Function ExportDataSheet(strFile, strSheet)

 

Dim objFS

 

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

 

' check that the xls doesn't already exist
If objFS.FileExists(strFile) Then

 

    ' delete it if it exists
    ObjFS.DeleteFile strFile

End If

 

' export the data table
DataTable.ExportSheet strFile, strSheet

 

' destroy the object
Set objFS = Nothing

 

End Function 'ExportDataSheet



Import a data table into your test at runtime.


' =============================================================
' function: ImportDataTable
' desc : Imports a data table
' params : strFile - full path of the xls file to import
' returns : void
' =============================================================

Function ImportDataTable(strFile)

 

Dim objFS

 

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

 

' check that the source file exists
If objFS.FileExists(strFile) Then

 

    ' import the data table
    DataTable.Import strFile

 

Else

 

    ' fail if the xls was not found
    Reporter.ReportEvent micFail, "Import Data Table""Unable to Import Data Table From '" & strFile & "', File Does Not Exist"

 

End If

 

' destroy the object
Set objFS = Nothing

 

End Function 'ImportDataTable

Export a data table at runtime.


' =============================================================
' function: ExportDataTable
' desc : Exports a data table
' params : strFile - full path to save the exported xls, note
' that any existing xls will be deleted
' returns : void
' =============================================================

Function ExportDataTable(strFile)

 

Dim objFS

 

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

 

' check that the xls doesn't already exist
If objFS.FileExists(strFile) Then

 

    ' delete it if it exists
    ObjFS.DeleteFile strFile

End If

 

' export the data table
DataTable.Export strFile

 

' destroy the object
Set objFS = Nothing

 

End Function 'ExportDataTable

Create Folder: Create a local or network folder.


' =============================================================
' function: FolderCreate
' desc    : Creates a folder
' params  : strFolderPath - the folder to create (full path)
' returns : void
' =============================================================

Function FolderCreate(strFolderPath)

 

Dim objFS

 

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

 

' create the folder
If Not objFS.FolderExists(strFolderPath) Then

    objFS.CreateFolder strFolderPath
End If

 

' destroy the object
Set objFS = Nothing
   
End Function 'FolderCreate

Copy Folder: Copy a local or network folder.


' =============================================================
' function: FolderCopy
' desc : Copys a folder and all of its files to a new path
' params : strSourceFolder - the folder to copy
' strDestinationFolder - the location to copy to
' returns : void
' =============================================================


Function FolderCopy(strSourceFolder, strDestinationFolder)

 

Dim objFS

 

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

 

' check that the source folder exists
If Not objFS.FolderExists(strSourceFolder) Then

 

     ' fail if the source does not exist
     reporter.ReportEvent micFail, "Copy Folder""Source Folder '"& strSourceFolder &"' Does Not Exist"

 

Else

 

     ' create the destination folder if it doesn't already exist
     If Not objFS.FolderExists(strDestinationFolder) Then
         objFS.CreateFolder(strDestinationFolder)
     End If

 

    ' copy the folder
    objFS.CopyFolder strSourceFolder, strDestinationFolder

End If

 

' destroy the object
Set objFS = Nothing

End Function
 'FolderCopy

 

 

Copy a file from one location to another.


' ============================================================= 
' function: FileCopy 
' desc : Copies a file from one location to another 
' params : strFile - full path to the source file 
' strTarget - the folder to copy the file to 
' returns : void 
' ============================================================= 
Function FileCopy(strFile, strTarget) 

Dim objFS 

' create a file system object 
Set objFS = CreateObject("Scripting.FileSystemObject") 

' check that the source file exists 
If Not objFS.FileExists(strFile) Then 

    ' fail if the source does not exist 
    reporter.ReportEvent micFail, "Move File""Unable to Copy the File '"& strFile &"', It Does Not Exist" 

Else 

    ' create the destination folder if it doesn't already exist 
    If Not objFS.FolderExists(strTarget) Then 
        objFS.CreateFolder(strTarget) 
    End If 

    ' copy the file 
    objFS.CopyFile strFile, strTarget 

End If 

' destroy the object 
Set objFS = Nothing 

End Function 'FileCopy 

Compare Files: Compare the contents of two text files


' =============================================================
' function: CompareFiles
' desc :    Compares two text files
' params :  strFile1 is the first file
'           strFile2 is the second file
' returns : True if they are the same, False otherwise
' =============================================================
Function CompareFiles(strFile1strFile2)

Dim objFS
Dim objFileAobjFileB
Dim strLineAstrLineB
dim intCompareResult

' create a file scripting object
Set objFS = CreateObject("Scripting.FileSystemObject")

' open each of the files for reading
Set objFileA = objFS.OpenTextFile(strFile11)
Set objFileB = objFS.OpenTextFile(strFile21)

' repeat the following until we hit the end of one of the files
Do While ((objFileA.AtEndOfStream <> TrueOR (objFileB.AtEndOfStream <> True))

    ' read the next line from both files
    strLineA = objFileA.ReadLine
    strLineB = objFileB.ReadLine

    ' perform a comparison on the line from each file
    intCompareResult = StrComp(strLineA,strLineB,0)

    ' if the value of the comparison is not 0, lines are different
    If (intCompareResult <> 0Then

        ' found a difference in the files, so close them both
        objFileA.Close
        objFileB.Close

        ' destroy the object
        Set objFS = Nothing

        ' return false
        CompareFiles = False

        ' exit the function
        Exit Function

    End If ' if different

Loop ' until end of file

' close both files
objFileA.Close
objFileB.Close

' destroy the object
Set objFS = Nothing

' if function got this far, means files are the same, so return True
CompareFiles = True

End Function 'CompareFiles