5:40 AM
GAReddy
0
QTP - Files Comparision
'************************************************************************
' GAReddy @ OneTestingCenter @ QTP @ Files Comparison
'************************************************************************
FilePath="D:\TestData\"
MyFile1="OnlineScriptLog.txt"
MyFile2="OnlineScriptLog1.txt"
ResultFile="D:\TestData\ResultFile.txt"
Call CompareFiles(FilePath, MyFile1, MyFile2)
Public Function CompareFiles(FilePath, MyFile1, MyFile2)
Const ForReading = 1
Const ForWriting = 2
Const BinaryCompare = 0
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set File1 = oFSO.OpenTextFile(FilePath & MyFile1, ForReading)
Set File2 = oFSO.OpenTextFile(FilePath & MyFile2, ForReading)
Set DiffFile=oFSO.CreateTextFile(ResultFile)
' *************************************************
' ****** To Count the number of lines in File1 ***********
'*************************************************
i=0
While File1.AtEndOfStream <> True
Line1 = File1.ReadLine
i=i+1
Wend
' *************************************************
' ****** To Count the number of lines in File2 ***********
'*************************************************
j=0
While File2.AtEndOfStream <> True
ln2 = File2.ReadLine
j=j+1
Wend
' *************************************************
' To Check if number of lines in File1 and File 2 are equal
'*************************************************
If i<>j Then
Reporter.ReportEvent 1, "Line Count ", "Line Count is not equal."
else
Reporter.ReportEvent 0, "Line Count ", "Line Count is equal."
End If
File1.Close
File2.Close
' *************************************************
' To Read text from both files to compare
'*************************************************
Set File1 = oFSO.OpenTextFile(FilePath&MyFile1, ForReading)
Set File2 = oFSO.OpenTextFile(FilePath&MyFile2, ForReading)
Do While ((File1.AtEndOfStream <> True) AND (File2.AtEndOfStream <> True))
' Do While ((File1.AtEndOfStream <> True))
File1Line=File1.Line
File2Line=File2.Line
File1ReadLine = File1.ReadLine
File2ReadLine = File2.ReadLine
Comp = StrComp( CStr(File1ReadLine),CStr( File2ReadLine), BinaryCompare)
' *************************************************
' To wrtie the comparison results on DiffFile
'*************************************************
If (Comp <> 0) then
DiffFile.WriteLine "Contents are different" &vbtab& File1Line &vbtab& CStr(File1ReadLine) &"***"& File2Line &vbtab& CStr(File2ReadLine)
Else
DiffFile.WriteLine "Contents are same" &vbtab & File1Line &vbtab& CStr(File1ReadLine)
End if
Loop
File1.Close
File2.Close
DiffFile.Close
End Function
'************************************************************************
5:39 AM
GAReddy
QTP - Excel Comparision
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' GAReddy @ OneTestingCenter @ QTP @ Excel Comparison
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ExcelFilePath="D:\GAReddy\OneTestingCenter\QTP\TestData\"
ExpectedExcelBook=" D:\GAReddy\OneTestingCenter\QTP\TestData\"QACompleteLearningReferense@AllOne.xls"
ActualExcelBook=" D:\GAReddy\OneTestingCenter\QTP\TestData\"QACompleteLearningReferense@AllOne1.xls"
DifferenseSheet="MyExcelSheet.xls"
ActualSheet="Automation Testing"
ExpectedSheet="Automation Testing"
Call ExcelCompare(ExcelFilePath,ExpectedExcelBook,ActualExcelBook,DifferenseSheet,ActualSheet,ExpectedSheet)
Function ExcelCompare(ExcelFilePath,ExpectedExcelBook,ActualExcelBook,DifferenseSheet,ActualSheet,ExpectedSheet)
Set oExcel=Createobject("Excel.Application")
Set oExpExcel=Createobject("Excel.Application")
Set oActExcel=Createobject("Excel.Application")
Set NewSheet = oExcel.Application.Workbooks.Add
Set MySheet=oExcel.Application.Activeworkbook.Worksheets("sheet1")
oActExcel.Workbooks.Open ActualExcelBook,2
oExpExcel.Workbooks.Open ExpectedExcelBook,2
Set oExpSheet=oExpExcel.Application.Activeworkbook.Worksheets(ExpectedSheet)
Set oActSheet=oActExcel.Application.Activeworkbook.Worksheets(ActualSheet)
RowsCount = oExpSheet.UsedRange.Rows.count
ColsCount = oExpSheet.UsedRange.Columns.count
RowsCount1= oActSheet.UsedRange.Rows.count
ColsCount1= oActSheet.UsedRange.Columns.count
For i=1 to RowsCount
For j=1 to ColsCount
If Trim(oExpSheet.Cells(i,j))<>Trim(oActSheet.Cells(i,j))Then
MySheet.Cells(i,j)=oExpSheet.cells(i,j) &" ***"& vbtab & oActSheet.cells(i,j)
MySheet.Cells(i,j).Interior.Colorindex=34
else
MySheet.Cells(i,j)=oExpSheet.Cells(i,j)
End If
Next
Next
MySheet.SaveAs ExcelFilePath&DifferenseSheet
oExcel.Quit
oExpExcel.Quit
oActExcel.Quit
Set oExcel=Nothing
Set oExpExcel=Nothing
Set oActExcel=Nothing
End Function
5:36 AM
GAReddy
QTP - VBScript Functions - One Reference
QTP - VBScript Functions - One Reference
VBScript Functions @ One Reference
| |
Date/Time Functions
| |
CDate:
|
Converts a valid date and time expression to the variant of subtype Date
|
Date:
|
Returns the current system date
|
DateAdd:
|
Returns a date to which a specified time interval has been added
|
DateAdd:
|
Returns a date to which a specified time interval has been added
|
DateDiff:
|
Returns the number of intervals between two dates
|
DatePart:
|
Returns the specified part of a given date
|
DateSerial:
|
Returns the date for a specified year, month, and day
|
DateValue:
|
Returns a date
|
Day:
|
Returns a number that represents the day of the month (between 1 and 31, inclusive)
|
FormatDateTime:
|
Returns an expression formatted as a date or time
|
Hour:
|
Returns a number that represents the hour of the day (between 0 and 23, inclusive)
|
IsDate:
|
Returns a Boolean value that indicates if the evaluated expression can be converted to a date
|
Minute:
|
Returns a number that represents the minute of the hour (between 0 and 59, inclusive)
|
Month:
|
Returns a number that represents the month of the year (between 1 and 12, inclusive)
|
MonthName:
|
Returns the name of a specified month
|
Now:
|
Returns the current system date and time
|
Second:
|
Returns a number that represents the second of the minute (between 0 and 59, inclusive)
|
Time :
|
Returns the current system time
|
Timer:
|
Returns the number of seconds since 12:00 AM
|
TimeSerial:
|
Returns the time for a specific hour, minute, and second
|
TimeValue:
|
Returns a time
|
Weekday:
|
Returns a number that represents the day of the week (between 1 and 7, inclusive)
|
WeekdayName:
|
Returns the weekday name of a specified day of the week
|
Year :
|
Returns a number that represents the year
|
Conversion Functions
| |
Asc:
|
Converts the first letter in a string to ANSI code
|
CBool:
|
Converts an expression to a variant of subtype Boolean
|
CByte:
|
Converts an expression to a variant of subtype Byte
|
CCur:
|
Converts an expression to a variant of subtype Currency
|
CDate:
|
Converts a valid date and time expression to the variant of subtype Date
|
CDbl:
|
Converts an expression to a variant of subtype Double
|
Chr:
|
Converts the specified ANSI code to a character
|
CInt:
|
Converts an expression to a variant of subtype Integer
|
CLng :
|
Converts an expression to a variant of subtype Long
|
CSng :
|
Converts an expression to a variant of subtype Single
|
CStr:
|
Converts an expression to a variant of subtype String
|
Hex:
|
Returns the hexadecimal value of a specified number
|
Oct:
|
Returns the octal value of a specified number
|
Format Functions
| |
FormatCurrency :
|
Returns an expression formatted as a currency value
|
FormatDateTime:
|
Returns an expression formatted as a date or time
|
FormatNumber:
|
Returns an expression formatted as a number
|
FormatPercent:
|
Returns an expression formatted as a percentage
|
Math Functions
| |
Abs:
|
Returns the absolute value of a specified number
|
Atn:
|
Returns the arctangent of a specified number
|
Cos:
|
Returns the cosine of a specified number (angle)
|
Exp:
|
Returns raised to a power
|
Hex:
|
Returns the hexadecimal value of a specified number
|
Int:
|
Returns the integer part of a specified number
|
Fix:
|
Returns the integer part of a specified number
|
Log:
|
Returns the natural logarithm of a specified number
|
Oct:
|
Returns the octal value of a specified number
|
Rnd:
|
Returns a random number less than 1 but greater or equal to 0
|
Sgn:
|
Returns an integer that indicates the sign of a specified number
|
Sin:
|
Returns the sine of a specified number (angle)
|
Sqr:
|
Returns the square root of a specified number
|
Tan:
|
Returns the tangent of a specified number (angle)
|
Array Functions
| |
Array:
|
Returns a variant containing an array
|
Filter :
|
Returns a zero::based array that contains a subset of a string array based on a filter criteria
|
IsArray:
|
Returns a Boolean value that indicates whether a specified variable is an array
|
Join:
|
Returns a string that consists of a number of substrings in an array
|
LBound:
|
Returns the smallest subscript for the indicated dimension of an array
|
Split:
|
Returns a zero::based, one::dimensional array that contains a specified number of substrings
|
UBound:
|
Returns the largest subscript for the indicated dimension of an array
|
String Functions
| |
InStr:
|
Returns the position of the first occurrence of one string within another. The search begins at the first character of the string
|
InStrRev:
|
Returns the position of the first occurrence of one string within another. The search begins at the last character of the string
|
LCase:
|
Converts a specified string to lowercase
|
Left:
|
Returns a specified number of characters from the left side of a string
|
Len:
|
Returns the number of characters in a string
|
LTrim:
|
Removes spaces on the left side of a string
|
RTrim:
|
Removes spaces on the right side of a string
|
Trim:
|
Removes spaces on both the left and the right side of a string
|
Mid:
|
Returns a specified number of characters from a string
|
Replace:
|
Replaces a specified part of a string with another string a specified number of times
|
Right :
|
Returns a specified number of characters from the right side of a string
|
Space:
|
Returns a string that consists of a specified number of spaces
|
StrComp:
|
Compares two strings and returns a value that represents the result of the comparison
|
String:
|
Returns a string that contains a repeating character of a specified length
|
StrReverse:
|
Reverses a string
|
UCase:
|
Converts a specified string to uppercase
|
Other Functions
| |
CreateObject:
|
Creates an object of a specified type
|
Eval:
|
Evaluates an expression and returns the result
|
GetLocale:
|
Returns the current locale ID
|
GetObject:
|
Returns a reference to an automation object from a file
|
GetRef:
|
Allows you to connect a VBScript procedure to a DHTML event on your pages
|
InputBox:
|
Displays a dialog box, where the user can write some input and/or click on a button, and returns the contents
|
IsEmpty:
|
Returns a Boolean value that indicates whether a specified variable has been initialized or not
|
IsNull :
|
Returns a Boolean value that indicates whether a specified expression contains no valid data (Null)
|
IsNumeric:
|
Returns a Boolean value that indicates whether a specified expression can be evaluated as a number
|
IsObject:
|
Returns a Boolean value that indicates whether the specified expression is an automation object
|
LoadPicture:
|
Returns a picture object. Available only on 32::bit platforms
|
MsgBox:
|
Displays a message box, waits for the user to click a button, and returns a value that indicates which button the user clicked
|
RGB:
|
Returns a number that represents an RGB color value
|
Round:
|
Rounds a number
|
ScriptEngine:
|
Returns the scripting language in use
|
ScriptEngineBuildVersion:
|
Returns the build version number of the scripting engine in use
|
ScriptEngineMajorVersion:
|
Returns the major version number of the scripting engine in use
|
ScriptEngineMinorVersion:
|
Returns the minor version number of the scripting engine in use
|
SetLocale:
|
Sets the locale ID and returns the previous locale ID
|
TypeName :
|
Returns the subtype of a specified variable
|
VarType:
|
Returns a value that indicates the subtype of a specified variable
|
Email Thi
GAReddy @ OneTestingCenter @ All Articles
- Ad-hoc Testing
- Automation Framework
- Basics of QTP
- Core Testing FAQs
- Download QTP - Preseenations
- Framework Guide
- Introduction to Testing
- ISTQB Foundation Level Exam Papers
- ISTQB Foundation Level Exam Sample Paper - I
- ISTQB Foundation Level Exam Sample Paper - II
- ISTQB Foundation Level Exam Sample Paper - III
- Keyword Driven Framework
- Keyword Driven Framework Complete Guide
- Keyword Framework Complete Guide
- Load
- Load Runner - Components
- Load Runner - Load Testing Process
- Load Testing - LoadRunner Correlation
- Load Testing Process
- Monkey Testing and Exploratory Testing
- Most Relevant Features and Benefits
- OneTestingCenter - Manual Testing - Learning Table
- Performance
- Performance Test - Short Notes
- Practical Guide to Keyword Driven Framework
- Programming Language / Scripting language / Markup languages / Operating Systems
- QTP QTP Learning Let's Learn QTP QTP Easy Learning QTP Guide QTP Book QTP Learning PDF QTP - Fundamentals QTP - Advanced QTP - Topic by Topic QTP Lessons GAReddy - QTP
- QTP - ActionDriven Framework Demo1
- QTP - Actions
- QTP - Application Relationship - Video
- QTP - Array Library Functions
- QTP - Automation Startup - Video
- QTP - Certification Q's1
- QTP - Certification Q's2
- QTP - Certification Q's3
- QTP - Data Tables
- QTP - DataTables - Video
- QTP - Descriptive Programing - Dynamic Object Repository Creation
- QTP - Descriptive Programming
- QTP - Descriptive Programming - Any Web App - Working with all Objects
- QTP - Descriptive Programming - Any Web App - Working with Web List-boxes
- QTP - Descriptive Programming - Broken Link Checking
- QTP - Descriptive Programming - Working with Any Web App
- QTP - Dictionary Object - Creating a Dictionary Object
- QTP - Dictionary Object - Add Method
- QTP - Dictionary Object - Items
- QTP - Dictionary Object - KeyExists
- QTP - Dictionary Object - Keys
- QTP - Dictionary Object - Remove Method
- QTP - Dictionary Object - RemoveAll Method
- QTP - Dictionary Object - Using Dictionary Values As Variables
- QTP - Environment Variables
- QTP - Excel - Excel Comparison
- QTP - Excel Comparision
- QTP - Files - Files Comparison
- QTP - Files Comparision
- QTP - Files Comparison
- QTP - FSO (PART A)
- QTP - FSO (PART B)
- QTP - Getting Object Properties Dynamically
- QTP - GetTOProperties / GetTOProperty / SetTOProperty Demo
- QTP - GetTOProperties Script Demo
- QTP - GetTOProperty Script Demo
- QTP - InputBox
- QTP - Keyword Driven Automation Framework - Video
- QTP - Keyword Driven Framework - Complete Guide
- QTP - Keyword Driven Framework - Complete Guide - Video
- QTP - Keyword Driven Framework - Step by Step Guide
- QTP - Microsoft Office - Word
- QTP - MsgBox
- QTP - Objects Classifications
- QTP - Overview
- QTP - Pass ByRef and Pass ByVal
- QTP - PDFs
- QTP - Recording Modes
- QTP - Recovery Scenario Manager
- QTP - Regular Expressions - Complete Reference
- QTP - Regular Expressions - Scripts
- QTP - Reporter Utility
- QTP - Reporter Utility - Scripts
- QTP - SetTOProperty Script Demo
- QTP - Synchronization
- QTP - Synchronization - Script Demo
- QTP - Synchronization Methods
- QTP - Synchronization Script
- QTP - Test / Action Template
- QTP - VBScript - Array Sorting
- QTP - VBScript - Dictionary Object
- QTP - VBScript and Data Types
- QTP - VBScript Functions - One Reference
- QTP - Videos
- QTP - Ways to synchronize
- QTP – Descriptive Programing – Any Web App - Working with Web Check Boxes
- QTP – Descriptive Programing – Examples
- QTP – Outlook Application
- QTP – Regular Expressions
- QTP – Web Tables
- QTP 10 Supports Windows 7 and IE8
- QTP Basics
- QTP Boks
- QTP Books
- QTP Complete Learning Table
- QTP Easy Learning
- QTP for Beginners
- QTP Info
- QTP Introduction
- QTP Learning
- QTP Learning MadeEasy. QTP QTP Learning Let's Learn QTP QTP Easy Learning QTP Guide QTP Book QTP Learning PDF QTP - Fundamentals QTP - Advanced QTP - Topic by Topic QTP Lessons GAReddy - QTP
- QTP Learning Materials
- QTP Simple
- QTP Videos
- Requirements Flow
- Roles and Responsibilities of Testers
- Software Testing - Core Testing Definitions
- Software Testing - FAQs
- Software Testing - Testing Methodologies
- Software Testing - Testing Process
- Software Testing Glossary : QA - Testing All in One
- Software Testing Process
- Stress Testing Requirements
- Stress testings
- Stress Testings - Why
- Test Case - Test Case Design Techniques
- Test Case - What is Test Case
- Test Case - What should a Test Case contain
- Test Case Designing Techniques
- Testing - Daily Status Report
- Testing - Defect - Defect Documenting
- Testing - Defect - Defect Life Cycle
- Testing - Defect - What is a Bug (Defect)
- Testing - Defect – Metrics
- Testing - Defect – Priority Levels
- Testing - Defect – Severity Levels
- Testing - Important FAQs
- Testing - Load Testing - Performance Testing - Stress Testing
- Testing - Requirements Flow
- Testing - UAT - Alpha Testing and Beta Testing
- Testing - Verification and Validation
- Testing Definitions
- Testing Methodologies
- Testing Terminologies
- VB Script Features
- What is Testing?
- When does the Testing begin?
- When does the Testing end?
- Why do we need Testing?
- Why does software have bugs?