QTP Concepts1
QTP Concepts1
Option explicit
2. Variables
Scalar Variables
Array Variables
Static Array and Dynamic Array
3. Object Repository
Local OR and Shared OR
4. Object Identification
0 Normal Identification
1 Mandatory Properties
2 Assistive properties
3 Ordinal Identifier
4 Smart Identification
5. OR Manager
10. Merging-Repositories
Conflicts:
Resolutions:
11. Descriptive Programming
Inline Programmingdone through passing string arguments
Programmatic Descriptive Programming:--Collection Objects
Working with Edit Box:
Working with Combo Boxes:
Working with Check Boxes:
Working with Radio Group:
Working with Web Table:
Working with Web Links:
5 Built-In functions
6 User defined Functions
Built-In Functions:
7 InStr(sString, sSubString) - Returns the position of the first occurrence of one string within another. The search
begins at the first character of the string
8 InStrRev(sString, sSubString) - Returns the position of the first occurrence of one string within another. The
search begins at the last character of the string
10 Left(sString, iLen) - Returns a specified number of characters from the left side of a string
14 Trim(sString) - Removes spaces on both the left and the right side of a string
16 Replace(sString, sOld, sNew) - Replaces a specified part of a string with another string a specified number of
times
17 Right(sString, iLen) - Returns a specified number of characters from the right side of a string
19 StrComp(sString1, sString2) - Compares two strings and returns a value that represents the result of the
comparison
20 String(iLen, sChar, iLen) - Returns a string that contains a repeating character of a specified length
FAQ s on VB Scripts:
VB script has only one Data Type Called Variant It holds different categories of Information:
3.What are the major differences between Visual Basic and VBScript?
13. DB Connection
Algorithm:
1. Create an ADODB.Connection object (the database object).
2. Set the connection string for the database object.
3. Open the connection to the database.
4. Execute a SQL statement.
5. Close the database connection.
Eg:
Dim con, rs
Set con=createobject ("adodb.connection") /*****Ado Connection Object Creation)
Set rs=createobject ("adodb.recordset") /**Record set object used to hold a set of
Records from a database table)
Con.open"provider=sqloledb.1; server=server2008; uid=vijay; Pwd=vijay"
rs.open "select *from person, /******selecting from Person table
Do while not rs.eof
Msgbox rs.field.item (1)
rs.moveNext
Loop
con.close
Open a file?
Delete Content?
File location = "C:\file_location"
Set fso = Create Object (Scripting.FileSystemObject)
fso.DeleteFile(file location)
15. Parameterization
17. Actions
27 Creating an Action
28 Splitting Actions
29 Renaming an Action
30 Deleting an Action
31 Making an Reusable/Non-Reusable
32 Calling an existing Action
33 Copying an Actions
34 Action Parameters
Dictionary:
Dictionary object is used with the index (key) being string. In the case of array, the index can be ONLY
numeric. Then of course we have some obvious advantages like referencing a value with a meaningful
keys etc.
Methods
Properties
Add Method:
dict.Add Company, HP Adding keys and corresponding items.
dict.Add Tool, Quickest Pro
dict.Add Website, LearnQTP
Exists Method:
If dict.Exists (Country) Then
msg = Specified key exists.
Else
msg = Specified key doesnt exist.
End If
'###############################################
'Create excel file and enter some data save it
'###############################################
'Make it Visible
Excel. Visible=True
'Release Variables
Set workbooks=Nothing
Set excel=Nothing
'###############################################
' Reading Values from a Specific excel Sheet
'###############################################
'Make it Visible
excel.Visible=True
'Release Variables
Set worksheet1=Nothing
Set workbook=Nothing
Set excel=Nothing
'###############################################
' Deleting Rows from Excel Sheet
'###############################################
'Make it Visible
excel.Visible=True
'Delete Row1
worksheet1.Rows("1:1").delete
'Save Excel
workbook.SaveAs("D:\excel.xls")
'Release Variables
Set worksheet1=Nothing
Set workbook=Nothing
Set excel=Nothing
'###############################################
' Add and Delete ExcelSheet
'###############################################
'Make it Visible
excel.Visible=True
'Assign a Name
newsheet.name="raj"
'Delete Sheet
Set delsheet=workbook.Sheets("raj")
delsheet.delete
'Release Variables
Set newsheet=Nothing
Set delsheet=Nothing
Set workbook=Nothing
Set excel=Nothing
'###############################################
' Copy an Excel Sheet of one Excel File to another Excel File
'###############################################
'Make it Visible
excel.Visible=True
'Close Workbooks
workbook1.Close
workbook2.Close
'Release Variables
Set workbook1=Nothing
Set workbook2=Nothing
Set excel=Nothing
'###############################################
' Comapre Two Excel Sheets Cell By Cell for a specific Range
'###############################################
'Make it Visible
excel.Visible=True
'Compare Values
If value1<>value2 Then
' If Values are not matched make the text with Red color
sheet2.cells(r,c).font.color=vbred
End If
Next
Next
'Save workbook
workbook.Save
'Release Variables
Set sheet1=Nothing
Set sheet2=Nothing
Set workbook=Nothing
Set excel=Nothing
'###############################################
' Reading complete data from excel file
'###############################################
'Make it Visible
excel.Visible=True
'Release Variables
Set worksheet=Nothing
Set workbook=Nothing
Set excel=Nothing
'###############################################
' Read complete data from an Excel Sheet content
'###############################################
'Make it Visible
excel.Visible=True
'Release Variables
Set worksheet=Nothing
Set workbook=Nothing
Set excel=Nothing
###############################################
' Assign Colours to Excel Sheet Cells, Rows
'###############################################
'Make it Visible
excel.Visible=True
'Save Excel
workbook.SaveAs("D:\excel.xls")
'Release Variables
Set objrange=Nothing
Set worksheet=Nothing
Set workbook=Nothing
Set excel=Nothing
Function GetAllEdits(Page)
Set GetAllEdits = GetAllSpecificControls(Page, "WebEdit")
End Function
Function GetAllButtons(Page)
Set GetAllButtons = GetAllSpecificControls(Page, "WebButton")
End Function
Function GetAllLinks(Page)
Set GetAllLinks = GetAllSpecificControls(Page, "Link")
End Function
Function GetAllImages(Page)
Set GetAllImages = GetAllSpecificControls(Page, "Image")
End Function
Frame work:
Hybrid:
Key Word Driven:
In Key Word Driven Framework the script values will be written in Excel files and QTP will execute them
using Driver Script
There are majorly two approaches followed to make Keyword Driven Framework.
1. Specify Script Values Directly in the Excel
2. Write Global Functions for each and every application control and specify those functions as keywords in
Excel
Approach 1:
Object Class : - Class of the object on which we are going to perform the operation
Object Properties: - Properties of the object
Operation :- The method to perform on the object
Value :- Input Data
We can specify properties directly in place of constants. But when you get a failure in the script, you might
not able to identify where exactly the error occurs
4. Open a new test in QTP and Save the test in C:\KeyWordDrivenSample\Scripts Folder with the
Name Driver Script Now you should have the Folder structure like specified below
Folder Structure:
Driver Script:
###################################################################
' Objective : This is a driver script for Sample Keyword Driven Framework
' Test Case : Driver Script
' Author : Vijay .Damaraju
' Date Created : 04/14/2011
' Date Updated : 04/14/2011
'Updated by : Sudhakar Kakunuri
'###################################################################
'##############Initialize Variables and Load Libraries#############################
Execute File "..\..\Constants\OR Constants.vbs"
'#####################Driver Script ######################################
'Add a new sheet and import keywords
Set dtKeyWords=DataTable.AddSheet("Keywords")
Datatable.ImportSheet "..\..\Keywords\ScriptKeywords.xls","Sheet1","Keywords"
'Get Row Count and Column Colunt of the databable
dtRowCount=dtKeyWords.GetRowCount
dtColumnCount=dtKeyWords.GetParameterCount
'Use for lop to get values row by row
For dtRow=1 to dtRowCount
dtKeyWords.SetCurrentRow (dtRow)
strObjClass = DataTable("ObjectClass","Keywords")
strObjProperties = DataTable("ObjectProperties","Keywords")
strOperation = DataTable("Operation","Keywords")
strValue = DataTable("Value","Keywords")
If strOperation="SetParent" Then
oParentObjectArray=Split(strObjClass,"/")
oParentObjectPropArray=Split(strObjProperties,"/")
For iParentCount=0 to ubound(oParentObjectArray)
iParent=oParentObjectArray(iParentCount)
iParentProps=oParentObjectPropArray(iParentCount)
If iParentCount=ubound(oParentObjectArray) Then
strParent=strParent&iParent&"("&""""&eval(iParentProps)&""""&")"
Exit For
End If
strParent=strParent&iParent&"("&""""&eval(iParentProps)&""""&")."
Next
ParentObject=strParent
Else
oStatement=ParentObject&"."&strObjClass&"("&""""& eval(strObjProperties) &""""&
")."& strOperation
If strValue<>"" Then
iStrInputDataArray=split(strValue,",")
For iInputValuesCount=0 to UBound(iStrInputDataArray)
If iInputValuesCount=UBound(iStrInputDataArray) Then
oStatement=oStatement&" "&""""& iStrInputDataArray(iInputValuesCount)
&""""
Exit for
End If
oStatement=oStatement&" "&""""& iStrInputDataArray(iInputValuesCount) &""""&","
Next
End If
Execute (oStatement)
End If
Next
'###################################################################
While executing your scripts you may get some UNEXPECTED/UNPREDICTABLE errors. (like
printer out of paper). To "recover" the test (and continue running) from these unexpected
errors you use Recovery Scenarios.
When to use "on error resume next" or programmatic handling of errors VS Recovery
Scenarios?
If you can predict that a certain event may happen at a specific point in your test or
component, it is recommended to handle that event directly within your test or component
by adding steps such as If statements or optional steps or "on error resume next", rather
than depending on a recovery scenario. Using Recovery Scenarios may result in unusually
slow performance of your tests. They are designed to handle a more generic set of
unpredictable events which CANNOT be handled programmatically.
For Example:
A recovery scenario can handle a printer error by clicking the default button in the
Printer Error message box.
You cannot handle this error directly in your test or component, since you cannot know at
what point the network will return the printer error. You could try to handle this event
in your test or component by adding an If statement immediately after the step that sent a
file to the printer, but if the network takes time to return the printer error, your test
or component may have progressed several steps before the error is displayed. Therefore,
for this type of event, only a recovery scenario can handle it.
Trigger Event. The event that interrupts your run session. For example, a window that may
pop up on screen, or a QTP run error.
Recovery Operations. The operations to perform to enable QTP to continue running the test
after the trigger event interrupts the run session. For example, clicking an OK button in
a pop-up window, or restarting Microsoft Windows.
Post-Recovery Test Run Option. The instructions on how QTP should proceed after the
recovery operations have been performed, and from which point in the test QTP should
continue, if at all. For example, you may want to restart a test from the beginning, or
skip a step entirely and continue with the next step in the test.
Recovery scenarios are saved in recovery scenario files having the extension .rs. A
recovery scenario file is a logical collection of recovery scenarios, grouped according to
your own specific requirements.
Eg: Script for selecting an item from combo box using its value.
//Script for selecting an Item from combo box using its Index:
Msgbox Count
If dialog(Login).winedit(agentName:).exists then
MsgboxThe text box exists
Else
msgbox textbox doesnot exists
Syntax:
Object Hierarchy.seton/off
Eg:
Window().checkbox(one).seton
To Uncheck:
Window().checkbox(one).setoff
Dialog(Login).winbutton(ok).click
A=dialog(Login).winbutton(ok).GetROProperty(enabled)
If a=True then
Msgbox(Ok Button is enabled)
Else
Msgbox (Ok Button is disabled)
End if
Interview Questions:
QTP Questions
Scripting Assignments:
www.gmail.com
Note: Practice these assignments for different Email providers (Yahoo, Hotmail.etc)
Ticket Booking:
Http://www.makemytrip.com
10.Write a script to find how many flights are available from Hyderabad to Delhi?
11.Write a script to find what is the cheapest price flight from Hyderabad to Delhi?
12.write a script to find how many buses are available from Hyderabad to Bangalore?
13.write a script to find the which is the earliest bus from Hyderabad to Bangalore?
14.write a script to find 27 seat No is occupied in earliest bus?
15.write a script to count how many seats are available?
16.write a script to find how many trains are available from Hyderabad to Tirupathi?
17.write a script to find which is the earliest train after 4 pm from Hyderabad to Tirupathi ?
18.write a script to find availability of berth in any of the train from Hyderabad to Tirupathi ?
http://www.kesinenitravels.com
19. Write a script to find how many ladies tickets are booked in a Bus?
Capture text of ToolTip
Place cursor over the link
Wait 1
Msgbox ToolTip
*******************************************************
Reference links:
http://www.softwaretestingtimes.com/2010/04/qtp-descriptive-programming-how-to-get.html
QTP Questions:
http://www.scribd.com/doc/7092347/QTP-Questions-Revised
Reference:
wop6957.tmpMicrosoft_Office_Word_97_-_2003_Document1.doc
Interview Questions:
VB
wop6A23.tmpMicrosoft_Office_Word_97_-_2003_Document2.doc
Scripts :
wop6A34.tmpMicrosoft_Office_Word_97_-_2003_Document3.doc
VB Script Features
Category Keywords
Array handling Array, Dim, Private, Public, ReDim, IsArray, Erase, LBound, UBound
Assignments Set
Comments Comments using ' or Rem
Constants/Literals Empty, Nothing, Null, True, False
Control flow Do...Loop, For...Next, For Each...Next, If...Then...Else, Select Case, While...Wend, With
Abs, Asc, AscB, AscW, Chr, ChrB, ChrW, CBool, CByte, CCur, CDate, CDbl, CInt, CLng, CSng, CStr,
Conversions
DateSerial, DateValue, Hex, Oct, Fix, Int, Sgn, TimeSerial, TimeValue
Date, Time, DateAdd, DateDiff, DatePart, DateSerial, DateValue, Day, Month, MonthName, Weekday,
Dates/Times
WeekdayName, Year, Hour, Minute, Second, Now, TimeSerial, TimeValue
Declarations Class, Const, Dim, Private, Public, ReDim, Function, Sub, Property Get, Property Let, Property Set
Error Handling On Error, Err
Expressions Eval, Execute, RegExp, Replace, Test
Formatting Strings FormatCurrency, FormatDateTime, FormatNumber, FormatPercent
Input/Output InputBox, LoadPicture, MsgBox
Literals Empty, FALSE, Nothing, Null, TRUE
Math Atn, Cos, Sin, Tan, Exp, Log, Sqr, Randomize, Rnd
Miscellaneous Eval Function, Execute Statement, RGB Function
Objects CreateObject, Err Object, GetObject, RegExp
Addition (+), Subtraction (-), Exponentiation (^), Modulus arithmetic (Mod), Multiplication (*),
Division (/), Integer Division (\), Negation (-), String concatenation (&), Equality (=), Inequality (<>),
Operators
Less Than (<), Less Than or Equal To (<=), Greater Than (>), Greater Than or Equal To (>=), Is, And,
Or, Xor, Eqv, Imp
Options Option Explicit
Procedures Call, Function, Sub, Property Get, Property Let, Property Set
Rounding Abs, Int, Fix, Round, Sgn
Script Engine ID ScriptEngine, ScriptEngineBuildVersion, ScriptEngineMajorVersion, ScriptEngineMinorVersion
Asc, AscB, AscW, Chr, ChrB, ChrW, Filter, InStr, InStrB, InStrRev, Join, Len, LenB, LCase, UCase,
Strings Left, LeftB, Mid, MidB, Right, RightB, Replace, Space, Split, StrComp, String, StrReverse, LTrim,
RTrim, Trim
Variants IsArray, IsDate, IsEmpty, IsNull, IsNumeric, IsObject, TypeName, VarType
oNumber=4
If oNumber mod 2 <>0 Then
Print "The Number "& oNumber &" is an Odd Number"
else
Print "The Number "& oNumber &" is not an Odd Number"
End If
'####################################################
'3 Print odd numbers between given range of numbers
Dim RangeStart
Dim RangeEnd
Dim iCounter
RangeStart=10
RangeEnd=20
Next
'####################################################
'4 Find the factorial of a given number
Dim oNumber
Dim iCounter
Dim fValue
oNumber=6
fValue=1
'####################################################
'5 Find the factors of a given number
Dim oNumber
Dim iCounter
oNumber=10
Dim RangeStart
Dim RangeEnd
Dim iCounter
RangeStart=1
RangeEnd=30
'####################################################
7 Swap 2 numbers with out a temporary variable
Dim oNum1
Dim oNum2
oNum1=1055
oNum2=155
oNum1=oNum1-oNum2
oNum2=oNum1+oNum2
oNum1=oNum2-oNum1
print oNum1
print oNum2
'####################################################
8 Write a program to Perform specified Arithmetic Operation on two given numbers
Dim oNum1
Dim oNum2
Dim oValue
oNum1=10
oNum2=20
OperationtoPerform="div"
Case "add"
oValue=oNum1+oNum2
Case "sub"
oValue=oNum1-oNum2
Case "mul"
oValue=oNum1*oNum2
Case "div"
oValue=oNum1/ oNum2
End Select
print oValue
'####################################################
9 Find the length of a given string
Dim oStr
Dim oLength
oStr="sudhakar"
oLength=len(oStr)
print oLength
'####################################################
10 Reverse given string
Dim oStr
Dim oLength
Dim oChar
Dim iCounter
oStr="sudhakar"
oLength=len(oStr)
oStr="su1h2kar"
oLength=len(oStr)
oAlphacounter=0
Next
print oAlphacounter
'####################################################
12 Find occurrences of a specific character in a string
Dim oStr
Dim oArray
Dim ochr
oStr="sudhakar"
ochr="a"
oArray=split(oStr,ochr)
print ubound(oArray)
'####################################################
13 Replace space with tab in between the words of a string.
Dim oStr
Dim fStr
fStr=replace(oStr," ",vbtab)
print fStr
'####################################################
14 Write a program to return ASCII value of a given character
Dim ochr
Dim aVal
ochr="A"
aVal=asc(ochr)
print aVal
'####################################################
15 Write a program to return character corresponding to the given ASCII value
Dim ochr
Dim aVal
aVal=65
oChr=chr(aVal)
print oChr
'####################################################
16 Convert string to Upper Case
Dim oStr
Dim uStr
oStr="QuickTest Professional"
uStr=ucase(oStr)
print uStr
'####################################################
17 Convert string to lower case
Dim oStr
Dim lStr
oStr="QuickTest Professional"
lStr=lcase(oStr)
print lStr
'####################################################
fStr=replace(oStr,oWord1,oWord2)
print fStr
'####################################################
19 Check whether the string is a POLYNDROM
Dim oStr
oStr="bob"
fStr=StrReverse(oStr)
If oStr=fStr Then
Print "The Given String "&oStr&" is a Palindrome"
else
Print "The Given String "&oStr&" is not a Palindrome"
End If
'####################################################
20 Verify whether given two strings are equal
Dim oStr1
Dim ostr2
oStr1="qtp"
oStr2="qtp"
If oStr1=oStr2 Then
Print "The Given Strings are Equal"
else
Print "The Given Strings are not Equal"
End If
'####################################################
21 Print all values from an Array
Dim oArray
Dim oCounter
oArray=array(1,2,3,4,"qtp","Testing")
'####################################################
22 Sort Array elements
Dim oArray
Dim oCounter1
Dim oCounter2
Dim tmp
oArray=array(8,3,4,2,7,1,6,9,5,0)
If oArray(oCounter2)>oArray(oCounter2+1) Then
tmp=oArray(oCounter2)
oArray(oCounter2)=oArray(oCounter2+1)
oArray(oCounter2+1)=tmp
End If
Next
Next
'####################################################
23 Add two 2X2 matrices
Dim oArray1(1,1)
Dim oArray2(1,1)
Dim tArray(1,1)
oArray1(0,0)=8
oArray1(0,1)=9
oArray1(1,0)=5
oArray1(1,1)=-1
oArray2(0,0)=-2
oArray2(0,1)=3
oArray2(1,0)=4
oArray2(1,1)=0
tArray(0,0)=oArray1(0,0)+ oArray2(0,0)
tArray(0,1)=oArray1(0,1)+oArray2(0,1)
tArray(1,0)=oArray1(1,0)+oArray2(1,0)
tArray(1,1)=oArray1(1,1)+oArray2(1,1)
'####################################################
Dim oArray1(1,1)
Dim oArray2(1,1)
Dim tArray(1,1)
oArray1(0,0)=8
oArray1(0,1)=9
oArray1(1,0)=5
oArray1(1,1)=-1
oArray2(0,0)=-2
oArray2(0,1)=3
oArray2(1,0)=4
oArray2(1,1)=0
'####################################################
25 Convert a String in to an array
Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr)
'####################################################
26 Convert a String in to an array using i as delimiter
Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr,"i")
'####################################################
27 Find number of words in string
Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr," ")
print "Theere are "&ubound(StrArray)+1&" words in the string"
'####################################################
28 Write a program to reverse the words of a given string.
Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr," ")
'####################################################
29 Print the data as a Pascal triangle
'The formulae for pascal triangle is nCr=n!/(n-r)!*r!
Dim PascalTriangleRows
Dim nCr
Dim NumCount
Dim RowCount
PascalTriangleRows = 10
For NumCount = 0 To PascalTriangleRows
toPrint= Space(PascalTriangleRows - NumCount)
For RowCount = 0 To NumCount
If (NumCount = RowCount) Then
nCr = 1
Else
nCr = Factorial(NumCount) / (Factorial(NumCount - RowCount) * Factorial(RowCount))
End If
toPrint=toPrint&nCr&" "
Next
print toPrint
Next
Function Factorial(num)
Dim iCounter
Factorial = 1
If num <> 0 Then
For iCounter = 2 To num
Factorial = Factorial * iCounter
Next
End If
End Function
'####################################################
30 Join elements of an array as a string
Dim oStr
Dim iCounter
oStr="Quick Test Professional"
StrArray=split(oStr," ")
'####################################################
31 Trim a given string from both sides
Dim oStr
'####################################################
32 Write a program to insert 100values and to delete 50 values from an array
Dim oArray()
Dim iCounter
ReDim oArray(100)
Dim x
x=10
'Here we get an error because i have not declared y,z
y=20
z=x+y
print z
'####################################################
34 Write a program to raise an error and print the error number.
'####################################################
35 Finding whether a variable is an Array
Dim oArray()
if isarray(oArray) then
print "the given variable is an array"
else
print "the given variable is not an array"
End if
'####################################################
36 Write a program to list the Timezone offset from GMT
Dim objWMIService
Dim colTimeZone
Dim objTimeZone
Next
'####################################################
38 Write a program to Convert an expression to a date
Dim StrDate
Dim actualDate
Dim StrTime
Dim actualTime
'####################################################
39 Display current date and Time
print now
'####################################################
40 Find difference between two dates.
'####################################################
41 Add time interval to a date
'####################################################
42 Print current day of the week
Print day(date)
'####################################################
43 Find whether current month is a long month
Dim oCurrentMonth
Dim ocurrentYear
Dim oDaysinMonths
oCurrentMonth = Month(date)
ocurrentYear = Year(date)
oDaysinMonths=Day(DateSerial(ocurrentYear, oCurrentMonth + 1, 0))
print oDaysinMonths&" Days in Current Month"
If oDaysinMonths=31 Then
print "Current Month is a long month"
else
print "Current Month is not a long month"
End If
'####################################################
44 Find whether given year is a leap year
'1st Method
Dim oYear
oYear=1996
If ((oYear Mod 4 = 0) And (oYear Mod 100 <> 0) Or (oYear Mod 400 = 0)) then
print "Year "&oYear&" is a Leap Year"
else
print "Year "&oYear&" is not a Leap Year"
End If
'####################################################
46 Format Number to specified decimal places
Dim oNum
Dim DecimaPlacestobeFormat
oNum = 3.14159
DecimaPlacestobeFormat=2
print Round(oNum , DecimaPlacestobeFormat)
'####################################################
47 Write a program to Generate a Random Numbers
'This script will generate random numbers between 10 and 20
Dim rStartRange
Dim rEndRange
rStartRange=10
rEndRange=20
For iCounter=1 to 10
print Int((rEndRange - rStartRange + 1) * Rnd + rStartRange)
Next
'####################################################
48 Write a program to show difference between Fix and Int
'Both Int and Fix remove the fractional part of number and return the resulting integer value.
'The difference between Int and Fix is that if number is negative, Int returns the first negative integer less than o
r equal to number,
'whereas Fix returns the first negative integer greater than or equal to number.
'For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
'####################################################
49 Write a program to find subtype of a variable
Dim oVar
Dim oDatatypes
oVar="QTP"
oVartype=Typename(oVar)
print oVartype
'####################################################
50 Write a program to print the decimal part of a given number
Dim oNum
oNum=3.123
oDecNum=oNum- int(oNum)
print oDecNum
'####################################################
A=Array(4,2,6,8,1)
Min =i
For j=i=1 to Ubound(a)
If a(j)<a(min) then
Min=j
End if
Next
S=a(i)
a(i)=a(min)
a(min)=s
end if
************************************************
Script to login ,Check the first mail and delete logout close
Systemutil.run www.yahoomail.com
With browser(creation time:=0).Page(micclass:=Page)
.webedit(Name:=Login).setmindqtest
.webedit(name:=password).setmindq12345
.webbutton(name:=signin).click
.webcheckbox(index:=1).click
.webbutton(Name:=delete,index:=0).click
End with
Browser(creation time:=0).close
Get the List of links in google webpage and check spelling check:
Dim d
Dim mw
Set d=description.create()
D(micclass).value=link
Set mw=createobject(word.application)
Set I =browser(google).Page(google).childobjects(d)
S=I(i).getRoProperty(Innertext)
Mw.wordbasic.filenew
Mw.wordbasic.insert s
If MW .activedocument.spellingerrors.count>0 then
Next
Mw.quit
Set mw.nothing
Author:Vijay
Prvmail=Fn_countmails
Browser(yahoo).Page(Inbox).webcheckbox(mid).set ON
Browser(Yahoo).Page(Inbox).webbutton(Delete).click
Wait(5)
Aftermails=Fn_countmails
If cint(aftermails)=prvmail.-1 then
Else
End if
Function Fn_Countmails
Dim msg ,n
Msg=browser(yahoo).Page(Inbox).webelement(Mailcount).
getROproperty(Innertext)
n=split(msg, )
fn_countmails=n(Ubound(n))
end function
******************************************************************8
StrXML=reqXML.Tostring()
Msgbox x
******************************************************************
F1=e:\b1.bmp
F2=e:\b2.bmp
Set bc=createobject(Mercury.filecompare)
If bc.isequalbin(F1,F2,0,1)then
Else
End if
Set bc=nothing