Normal 0 false false false EN-US X-NONE X-NONE w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false"...
Saturday, 27 August 2011
QTP - Excel - Excel Comparison
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' 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...
Friday, 26 August 2011
QTP - VBScript Functions - One Reference
Normal 0 false false false EN-US X-NONE X-NONE w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"> w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/> w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false"...
Saturday, 27 August 2011
QTP - Files - Files Comparison
'************************************************************************
' 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
'************************************************************************
QTP - Excel - Excel Comparison
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' 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
Friday, 26 August 2011
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 |
|
Subscribe to:
Posts (Atom)