Thursday, June 17, 2010

Shortcut key in QTP

  •  Normal Record Mode := F3
  • Analog Record Mode := Shift+alt+F3
  •  Low level Recording := Ctrl+shift+F3
  •  Stop Recording : =F4
  •  Run the Script := F5
  • comment block := Ctrl + M
  • Uncomment Block := Ctrl+Shift+M
  • Standard checkpoint := F12
  • Step Generator := F7
  • Run from Step: = Ctrl+F5
  • Step Info := F11
  • Step Out: = F10
  • Step Out: = Shift+F11
  • Run to Step := Ctrl+F10
  • Add to Watch: = Ctrl+T
  • Insert/ Remove Breakpoint: = F9
  • Enable / disable Breakpoint := Ctrl +F9
  • Clear All Breakpoints:= Ctrl+Shift+F9
  • Syntax Check := Ctrl + F7

Explain the difference between Keyword view and Expert view

Keyword view:

Keyword is a table view structure, it represent for each row for part of the action. It contain following view as below like “item, operation, value, documentation, assignment and comments “

Item
Represent hierarchical tree view of the Test object within the table. It contains following items available on
·         Test object
·         Utility object
·         Function call
·         Statement




Operation 

What operation should be performed for each test objects in the table view like..
·         Run
·         Set
·         Secure
·         Enter
·         Type
·         Select
·         Close


Value
File location, Path , Value, Inputs of the each Test objects








Documentation
It will capture the file location; Test objects inputs and each to understand the each test objects what does for the test objects in the application

Expert View:

QTP displays each step as a VBScript line or statement. In object-based steps, the VBScript statement defines the object hierarchy
Note: Test object and method names are not case sensitive
The following diagram shows how the same object hierarchy is displayed in the Expert View and in the Keyword View


Wednesday, June 16, 2010

Descriptive Programming in QTP

Object Repository:
Ø  OR is a place to stores QTP learned objects
Ø  QTP uses default Object Identification properties: mandatory and assistive to learn objects into OR
Script play back using OR
-          QTP find the Objects in OR using Logical name and Object hierarchy
-          QTP retrieve the test object properties from OR
-          QTP search the application for the object with the same object in OR and perform the user action
Descriptive Programming:
v  Learn the object Properties and physical description of the objects and used into Script level
v  Descriptive properties is store Script level

Script play back using Descriptive programming
-          QTP search the AUT for the Object using Descriptive properties and performs user action
How to use the Descriptive programming
They are two ways in which descriptive programming can be used as below

1)    By creating properties for collection of Objects or Child Objects
    We can use description object to get all the objects on the page that matches that specific description. Suppose we have to check all the checkboxes present on a web page. So we will first create an object description for a checkbox and then get all the checkboxes from the page

Dim obj_ChkDesc
Set obj_ChkDesc=Description.Create
obj_ChkDesc(“html tag”).value = “INPUT”
obj_ChkDesc(“type”).value = “checkbox”
Dim allCheckboxes, singleCheckBox
Set allCheckboxes = Browse(“Browser”).Page(“Page”).ChildObjects(obj_ChkDesc)
For each singleCheckBox in allCheckboxes
             singleCheckBox.Set “ON”
Next

2)    By creating properties for Single Objects
        When going for single or specific point within a test object hierarchy, you must create descriptive properties from starting onwards
For Example,
Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "vinodh"
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Type  micTab
Dialog("text:=Login").WinEdit("attached text:=Password:").SetSecure "4c18d6c06f2d8fe29ad434c54106936bc9199553"
Dialog("text:=Login").WinButton("regexpwndtitle:=OK").Click
Window("text:=Flight Reservation").Close
Note: If initially of the code used OR objects after that, if used descriptive properties, QTP doesn’t recognize  the objects
For example
Dialog("text:=Login").WinButton("OK").Click
Error:

QTP support following applications for Automation

Default Add-ins
v  ActiveX
v  Visual basic
v  Web
Other Add-Ins
v  Siebel
v  Java
v  SAP
v  Oracle
v  Delphi
v  .Net 

Names of the Products and Vendor for Automation tools

Tool Name
Company Name
Latest Version
HP
10
IBM Rational
8.1.0.3
IBM Rational
2001
OpenSource Tool
1.0.6
Micro Focus
2009
AutomatedQA
7.52
Micro Focus
6.3
WATIR
Open Source tool
1.6.5

The benefits of Effective Test Automation

1) Cost Effective
2) Time is saved
3) Reusable the automation scripts
4) Human resources is reduce
5) Support the Development process

Object Spy in QTP

Object spy pointing mechanism for view the supported properties and methods of spy objects. Click on the “Hand symbol” button and select the window or object , it will display the Properties and value of the objects

There are two ways to Spy the objects in QTP
1) Choose Tools-> Object Spy
2) Object repository Dialog

Note:- The Application or object is not visible, hold the Ctrl button and Click or activate the required window to and release the Ctrl button

Object repository in QTP

Understand the Object Repository:
          While Record the Application, Manually Define or Add the Objects it stored into Object Repository. All Objects displayed in the tree view
v  Name:- Name of the Objects
v  Class: Class of the objects
v  Repository : Repository location and Default like “ Local”
v  Test Object details:
v  Description Properties: View/Modify the object’s properties and property value.
v  Ordinal Identifier : It indicate the Identifier Type – Location or Index  and Value 0(Default value)
v  Additional details : it will display Smart Identification is disable or enable and comments
Add the Objects into OR
v  Ctrl+ R (or) Resources -> Object Repository. Select  “Add object to Local” button, highlight the application or window, it will capture all the objects and stored into Object Repository 

Tuesday, June 15, 2010

Recovery scenario manager for QTP

Unexpected events, errors, and application crashes during a running session can disrupt your application and execution section. This is a problem particularly when tests run unattended window or pop-up or Notification. The test pauses until you perform the operation needed to recover.

QTP enables you to create recovery scenarios and associate them with specific tests. Recovery scenarios activate specific recovery operations when trigger events occur.

Define the Recovery scenario
1.    Trigger Event:-
      Pop-up window:-Pops up window an opened the applications during the test run
               Object State: - Object identification issue in our application not match specified value
               Test Run:- Step in your test does not run successfully
               Application crash: Open applications fails during the run times

2.    Recovery Event
     Select the operation to perform when the trigger event occurs
Operation type
               Keyboard or Mouse Operation
               Close application process
               Function call
               Restart the OS (windows)

3.    Post Recovery Event
The recovery operations have been performed and which point in the test or QTP should be continue, the following steps are available in QTP like
     Repeat current Step and Continue
     Proceed to next step
     Proceed to next action or component iteration
     Proceed to next test iteration
     Restart current test run
     Stop the test run

Finally entered the recovery scenario name and saved the operation

Features & Benefits of Quick Test Professional


  • ·         Key word driven and Expert view testing
  • ·         Suitable for both client server, web based application, Oracle Apps, SAP
  • ·         Handling object using Object Repositions manager
  • ·         Descriptive Programming
  • ·         Script language for VB scripts
  • ·         Error handling mechanism
  • ·         Excellent data driven testing features using external File like Excel and Notepad
  • ·         Object Spy and Object Identification feature
  • ·         Verify the file ,text, image and data from database using check points
  • Recovery scenario



Friday, June 11, 2010

VarType Function

' To check the Variable type using Vb Scripts
'vbArray
myArray = Array(20)
If VarType(myArray) And vbArray Then MsgBox " Array Variable"

'vbBoolean
myBoolean = True
If VarType(myBoolean) And vbBoolean Then MsgBox "Boolean Variable"

'vbnull
myNull = Null
If VarType(myNull) And vbNull Then MsgBox "Null Variable"

'vbEmpty
myEmpty = Empty
If VarType(myEmpty) And vbEmpty Then MsgBox "Empty Variable"

'vbDecimal
myDecimal = 23.23423
If VarType(myDecimal) And vbDecimal Then MsgBox "Decimal Variable"

VbInteger 
myInteger = 123
If VarType(myInteger) And vbInteger Then MsgBox "Integer Variable"

'vbCurrency
myCurrency = 23323
If VarType(myCurrency) And vbCurrency Then MsgBox "Currency Variable"

vbSingle 
mySingle = 2.344
If VarType(mySingle) And vbSingle Then MsgBox "Single Variable"

VbDouble 
myDouble = 92349.3405034
If VarType(myDouble) And vbdouble Then MsgBox "Double Variable"

VbLong
myLong = 1243242343423#
If VarType(myLong) And vbLong Then MsgBox "Long Variable"

VbDate
MyDate = Date
If VarType(MyDate) And vbDate Then MsgBox "Date Variable"

FormatDatetime Function

Syntax:
FormatDateTime(Date[,NameFormat])

Name of the Format:
vbGeneralDate vbLongDate vbShortDate vbLongTime VbShortTime

Code:
Dim TDate, MyReturn
TDate = Now
MyReturn = FormatDateTime(TDate, vbGeneralDate)
MsgBox MyReturn

FormatPercentage Function

The function returns an expression formatted as a percentage (multiplied by 100) with a trailing % character.

Dim MyValue, MyReturn
MyValue = 3459459.345
MyReturn = FormatPercent(MyValue, 1, vbUseDefault, vbUseDefault, vbUseDefault)
MsgBox MyReturn

MyReturn = FormatPercent(1000.578) ' Returns 57.80%
MyReturn = FormatPercent(1000.578, 1) ' Returns 57.8%
MyReturn = FormatPercent(1000.578, 3) ' Returns 57.800%
MyReturn = FormatPercent(.578,,True) ' Returns 57.80%
MyReturn = FormatPercent(.578,,False) ' Returns 57.80%
MyReturn = FormatPercent(-1000.578,,,True) ' Returns (57.80%)
MyReturn = FormatPercent(-1000.578,,,False) ' Returns -57.80%
MyReturn = FormatPercent(1000000.578,,,,True) ' Returns 57.80%
MyReturn = FormatPercent(1000000.578,,,,False) ' Returns 57.80%

FormatNumber Function

Returns an expression formatted as a number

Dim MyValue, MyReturn
MyValue = 3459459.3453454
MyReturn = FormatNumber(MyValue, 10, vbUseDefault, vbUseDefault, vbUseDefault)
MsgBox MyReturn

MyReturn = FormatNumber(1000.578) ' Returns 1,000.58
MyReturn = FormatNumber(1000.578, 1) ' Returns 1,000.6
MyReturn = FormatNumber(1000.578, 3) ' Returns 1,000.578
MyReturn = FormatNumber(.578,,True) ' Returns 0.58
MyReturn = FormatNumber(.578,,False) ' Returns $.58
MyReturn = FormatNumber(-1000.578,,,True) ' Returns (1,000.58)
MyReturn = FormatNumber(-1000.578,,,False) ' Returns -1,000.58
MyReturn = FormatNumber(1000000.578,,,,True) ' Returns 1,000,000.58
MyReturn = FormatNumber(1000000.578,,,,False) ' Returns 1000000.58

FormatCurrency Function

Returns an expression formatted as a currency value using the currency symbol defined in the computer's control panel.
Dim MyValue, MyReturn
MyValue = 3459459.3453454
MyReturn = FormatCurrency(MyValue, 6, vbUseDefault, vbUseDefault, vbUseDefault)
MsgBox MyReturn

Result like

MyReturn = FormatCurrency(1000.578) ' Returns $1,000.58
MyReturn = FormatCurrency(1000.578, 1) ' Returns $1,000.6
MyReturn = FormatCurrency(1000.578, 3) ' Returns $1,000.578
MyReturn = FormatCurrency(.578,,True) ' Returns $0.58
MyReturn = FormatCurrency(.578,,False) ' Returns $.58
MyReturn = FormatCurrency(-1000.578,,,True) ' Returns ($1,000.58)
MyReturn = FormatCurrency(-1000.578,,,False) ' Returns -$1,000.58
MyReturn = FormatCurrency(1000000.57,,,,True) ' Returns $1,000,000.57
MyReturn = FormatCurrency(1000000.57,,,,False) ' Returns $1000000.57

Rnd Function

Dim MyValue, MyReturn
MyReturn = Rnd(100)
MsgBox MyReturn

ASC -String Manipulation Function

It represents the character code or Unicode of the first character of the string.

Dim myval
myval = "Z"
MyReturn = Asc(myval)
MsgBox MyReturn

Chr Function

Dim myval, MyReturnchr,
MyReturnchr = Chr(97)
MsgBox "CHR Code Is:" & MyReturnchr

Instr Function

Dim MyVal1, MyVal2
MyVal1 = "Welcome to India"
MyVal2 = "India"
MyInstr = InStr(10, MyVal1, "India", 0)
MsgBox MyInstr

Instrrev Function

Dim MyVal1, MyVal2,MyInstrRev
MyVal1 = "Welcome to India"
MyVal2 = "India"
MyInstrRev = InStrRev(MyVal1, "India",10,0)
MsgBox MyInstrRev

String Function

The String function returns a repeating character string of the length specified.
Dim MyReturn
MyReturn = String(16, "Automation Testing")
MsgBox MyReturn

ABS Function

It will return the absolute value or positive value of the number
Dim MyValue, MyReturn
MyValue = -34.2345325
MyReturn = Abs(MyValue)
MsgBox MyReturn

Atn Function

It returns arctangent of the number
Dim MyValue, MyReturn
MyValue = 3
MyReturn = Atn(MyValue)
MsgBox MyReturn

COS Function

Dim MyValue, MyReturn
MyValue = 3
MyReturn = Cos(MyValue)
MsgBox MyReturn

Sin Function

The sin of an angle
Dim MyValue, MyReturn
MyValue = 3
MyReturn = Sin(MyValue)
MsgBox MyReturn

Tan Function

It returns the tangent of an angle
Dim MyValue, MyReturn
MyValue = 3
MyReturn = Tan(MyValue)
MsgBox MyReturn

Log Function

Function returns the natural logarithm of the number
Dim MyValue, MyReturn
MyValue = 3
MyReturn = Log(MyValue)
MsgBox MyReturn

Exp Function

The Exp function returns the antilogarithm of a number
Dim MyValue, MyReturn
MyValue = 3
MyReturn = Exp(MyValue)
MsgBox MyReturn

Sqr Function

It returns calculates the square root of the given number
Dim MyValue, MyReturn
MyValue = 3
MyReturn = Sqr(MyValue)
MsgBox MyReturn

Int Function

Function returns the integer portion of the number
Dim MyValue, MyReturn
MyValue = 3.653
MyReturn = Int(MyValue)
MsgBox MyReturn

MyInt = Int(99.8) ' Returns 99.
MyInt = Int(-99.8) ' Returns -100.
MyInt = Int(-99.2) ' Returns -100.
MyInt = Int(6.83227) ' Returns 6
MyInt = Int(6.23443) ' Returns 6
MyInt = Int(-6.13443) ' Returns -7
MyInt = Int(-6.93443) ' Returns -7

Fix Function

The Fix function returns the integer part of a specified number.
Dim MyValue, MyReturn
MyValue = 3.653
MyReturn = Fix(MyValue)
MsgBox MyReturn
It may return like
nFix = Fix(99.2) ' Returns 99.
nFix = Fix(-99.8) ' Returns -99.
nFix = Fix(-99.2) ' Returns -99.
nFix = Fix(6.83227) ' Returns 6
nFix = Fix(6.23443) ' Returns 6
nFix = Fix(-6.13443) ' Returns -6
nFix = Fix(-6.93443) ' Returns -6

Hex function

Returns a string that represents the hexadecimal value of a specified number.

Dim MyValue, MyReturn
MyValue = 3.653
MyReturn = Hex(MyValue)
MsgBox MyReturn

Oct function

Dim MyValue, MyReturn
MyValue = 3.653
MyReturn = Oct(MyValue)
MsgBox MyReturn

Sgn Function

Dim MyValue, MyReturn
MyValue = 3.653
MyReturn = sgn(MyValue)
MsgBox MyReturn

Round Function

The Round function rounds a given number to a specified number of decimal places
Dim MyValue, MyReturn
MyValue = 524324.899
MyReturn = Round(MyValue, 1)
MsgBox MyReturn

Tuesday, June 8, 2010

Msgbox - Interaction Function

Display the user information as a dialog box message
Syntax
MsgBox(prompt, buttons, title, helpfile, context)
Code
Dim MyVal
MyVal = “Welcome To all”
Msgbox MyVal

InputBox -Interaction Functions

The InputBox function displays a dialog box containing a label. The data you expect from the users, an OK button
Syntax
InputBox(prompt,title,default,xpos, ypos, helpfile, context)
Code
Dim MyInput
MyInput = InputBox("Window Description", "Window Title - InputBox Function ", " Enter Ur Name", 50, 60, "Enter String Value", 20)
'(or)
MyInput = InputBox("Enter Ur Name")
MsgBox MyInput

Monday, June 7, 2010

GetCellData

Function name: GetCellData
Purpose: To fetch values from the cell specified Row and Column of the Grid Control
Definition: GetCellData(int nRow, int nCol)
Parameters:
nRow: Index of the Row to fetch Cell Value
nCol: Index of the Column to fetch Cell Value
Returns: Value in the specified cell
Usage:
Browser(Obj).Page(Obj).Webtable(Obj).GetCellData (4,4)

Execute File Function

This can be used to execute an external VB Script File
Syntax: ExecuteFile FileName
Example : ExecuteFile “C:\sample.vbs”
The above discussed functions can be easily accessed by step Generator:

When working in the Expert View, you should bear in mind the following general VBScript syntax rules and guidelines

• Case-sensitivity—By default, VBScript is not case sensitive and does not differentiate between upper-case and lower-case spelling of words, for example, in variables, object and method names, or constants.

For example, the two statements below are identical in VBScript:
Browser("Mercury").Page("Find a Flight:").WebList("toDay").Select "31"
browser("mercury").page("find a flight:").weblist("today").select "31"

Text strings—When you enter a value as a text string, you must add quotation marks before and after the string. For example, in the above segment of script, the names of the Web site, Web page, and edit box are all text strings surrounded by quotation marks. Note that the value 31 is also surrounded by quotation marks, because it is a text string that represents a number and not a numeric value.

In the following example, only the property name (first argument) is a text string and is in quotation marks. The second argument (the value of the property) is a variable and therefore does not have quotation marks. The third argument (specifying the timeout) is a numeric value, which also does not need quotation marks.
Browser("Mercury").Page("Find a Flight:").WaitProperty("items count", Total_Items, 2000)
• Variables—You can specify variables to store strings, integers, arrays and objects. Using variables helps to make your script more readable and flexible. For more information, see Using Variables.
• Parentheses—To achieve the desired result and to avoid errors, it is important that you use parentheses () correctly in your statements. For more information, see Using Parentheses.

• Comments—You can add comments to your statements using an apostrophe ('), either at the beginning of a separate line, or at the end of a statement. It is recommended that you add comments wherever possible, to make your scripts easier to understand and maintain.

• Spaces—You can add extra blank spaces to your script to improve clarity. These spaces are ignored by VBScript.

To specify a variable refer to an object, use the Set statement, with the following syntax:
Set ObjectVar = ObjectHierarchy
In the example below, the Set statement specifies the variable UserEditBox to store the full Browser > Page > WebEdit object hierarchy for the username edit box. The Set method then enters the value John into the username edit box, using the UserEditBox variable:
Set UserEditBox = Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username")
UserEditBox.Set "John"

Note: Do not use the Set statement to specify a variable containing a simple value (such as a string or a number). The example below shows how to define a variable for a simple value:
MyVar = Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").GetTOProperty("type")
You can also use the Dim statement to declare variables of other types, including strings, integers, and arrays. This statement is not mandatory, but you can use it to improve the structure of your test or component. In the following example, the Dim statement is used to declare the passengers variable, which can then be used in different statements within the current action.

Dim passengers
passengers = Browser("Mercury Tours").Page("Find Flights").WebEdit("numpassengers").GetROProperty("value")

Friday, June 4, 2010

Software Automation testing Focus:

Core Business Case Development:
Identified the core area of the business and will be cost-effective and efficient.

Technical Feasibility
Determine the technical feasibility of automated tests given the environment, applications, databases, platforms, and architectures of the target system. It will provide the appropriate automation tools given the client environment.

Generation and execution:
Plan, design, generate and execute the automation scripts. Observe the process to ensure proper execution per the plan.

Analysis of performance, coverage, and cost effectiveness:
Analyze the results of the tests to verify that the automation goals are achieved. Verify code and test coverage.

Advanced Test Design:
This advanced technique, to verify systems that have high-reliability, low-defect on automation scripts.

Migration of automation systems:
To easy to translate the automate test system to another.

Swap 2 numbers without using any temporary variable

Dim a, b, c
a = 100
b = 200
a = a + b
b = a - b
a = a - b
MsgBox " A amount IS : " & a
MsgBox " B amount IS : " & b

Thursday, June 3, 2010

Program to find subtype of a variable

Dim MyValue, MyVal, MyReturn
MyValue = "Welocme To All"
MyReturn = TypeName(MyVal)
MsgBox MyReturn
MyReturn = TypeName(MyValue)
MsgBox MyReturn

Difference between Fix and Int

Dim MyValue, MyVal, MyReturn
MyVal = -9874.43875
MyReturn = Fix(MyVal)
MsgBox MyReturn
MyReturn1 = Int(MyVal)
MsgBox MyReturn1

Generate a Random Number

Dim MyString, MyReturn
MyReturn = 10
MyValue = Int((100 * Rnd) + 1)
MsgBox MyValue
If (MyValue = MyRetrun) Then
MsgBox " Equal"
Else
MsgBox " Not Equal"
End If

Format Number to specified decimal places

Dim MyValue, MyReturn
MyValue = 93864934.0238923
MyReturn = Round(MyValue, 10)
MsgBox MyReturn
Or
IF you were entered more Decimal value,System thru error message
MyValue = 93864934.0238923
MyReturn = Round(MyValue, 100)
MsgBox MyReturn

Find leap year

Dim MyYear
'MyYear = Year(Date)
MyYear = 2016
If (MyYear / 4 = MyYear \ 4) Then
MsgBox " Leap Year"
Else
MsgBox "Not a Leap Year"
End If

Print current day of the week

Dim MyDate, MyReturn
MyDate = "January 11, 1981"
MyReturn = Weekday(MyDate, vbSunday)
MsgBox MyReturn
(Or)
Dim MyDate, MyReturn
MyDate = Date
MsgBox MyDate
MyReturn = Weekday(MyDate, vbUseSystemDayOfWeek)
MsgBox MyReturn

Add time interval to a date

Dim MyDate, MyReturn
MyDate = "January 11, 1981"
MyReturn = DateAdd("YYYY", 29, MyDate)
MsgBox MyReturn

Find difference between two dates.

Dim MyDate, MyReturn
MyDate = "January 11, 1981"
MyCurDate = Date
MyReturn = DateDiff("YYYY", MyDate, MyCurDate)
MsgBox MyReturn

Display current date and Time

Dim MyDate, MyTime
MyDate = Date
MsgBox MyDate
MyTime = Time
MsgBox MyTime

Convert an expression to a date

Dim MyDate, MyReturn
MyDate = "January 11, 1981"
MyReturn = CDate(MyDate)
MsgBox MyReturn

Convert value into a currency

Dim MyValue, MyReturn
MyValue = 3583587
MyReturn = FormatCurrency(MyValue)
MsgBox MyReturn

Find whether a variable is an Array

Dim MyString As Variant, MyReturn As Variant
MyString = Array(10, 20, 30)
If (IsArray(MyString)) Then
MsgBox "True"
Else
MsgBox "False"
End If

program to force the declaration of variables

Option Explicit
Dim MyString, MyReturn
MyString = " VBScript is fun! "
'MyReturn = Trim(MyString)
MsgBox MyReturn

Trim a given string

Dim MyString, MyReturn
MyString = " VBScript is fun! "
MyReturn = Trim(MyString)
MsgBox MyReturn
MyReturn2 = LTrim(MyString)
MsgBox MyReturn2
MyReturn1 = RTrim(MyString)

Write a program to reverse the words of a given string

Dim MyString, MyReturn
MyString = "VBScriptXisXfun!"
MyReturn = StrReverse(MyString)
MsgBox MyReturn

Find number of words in string

Dim MyString, MyReturn
MyString = "VBScriptXisXfun!"
MyReturn = Len(MyString)
MsgBox MyReturn

Verify whether given two strings are equal

Dim MyString1, MyString2
MyString1 = ("India")
MyString2 = ("India")
MyReturn = StrComp(MyString1, MyString2, vbTextCompare)
If (MyReturn = 1) Then
MsgBox MyReturn & " string1 is greater than string2"
ElseIf (MyReturn = 0) Then
MsgBox MyReturn & "string1 is equal to string2"
ElseIf (MyReturn = -1) Then
MsgBox MyReturn & "string1 is less than string2"
Else
MsgBox MyReturn & "string1 or string2 is Null"
End If

Replace a word with another word

Dim MyString, MyInput, MyReturn
MyString = UCase("Welocme To India")
MyInput = UCase("ALL")
MyReturn = Replace(MyString, "INDIA", MyInput)
MsgBox MyReturn

Convert into Lower case

Dim MyString
MyString = LCase("Welocme To India")
MsgBox MyString

Convert string to Upper Case

Dim MyString
MyString = UCase("Welocme To India")
MsgBox MyString

Find whether given number is an odd number

If (a / 2 = a \ 2) Then
MsgBox a & "Even Number"
Else
MsgBox a & "Add Number"
End If

Find occurrences of a specific character in a string

Dim MyString
MyString = "welcome"
MyReturn = Left(MyString, 1)
MsgBox MyReturn

Return the reverse a string or number

a = 987654321
b = StrReverse(a)
MsgBox b
Aa = "llA ot emoclew"
Bb = StrReverse(Aa)
MsgBox Bb

Find the length of a given string

a = 129463265
MsgBox (Len(a))

Arithmetic Operation on two given numbers

Dim a, b, c, result
a = 10
b = 2
result = a + b
MsgBox result
result = a - b
MsgBox result
result = a / b
MsgBox result
result = a * b
MsgBox result
result = a ^ b
MsgBox result

Print odd numbers between given range of numbers

For i = 0 To 100 Step 1
If (i / 2 = i \ 2) Then
MsgBox i & "Even Number"
Else
MsgBox i & "Add Number"
End If
Next

Return the no. of the character in a string or number

a = 444
b = Len(a)
MsgBox b

Program to Import an excel file to a Data table

Datatable.import(“C:\Test\Excel.xlsx”)

Program to Read data from first parameter of Global sheet

Browser(Obj).Page(Obj).WebEdit(Obj).Select Cint(DataTable(“UserName”,”GlobalSheet”)
(Or)
DataTable.Value(“UserName”,”Globalsheet”)

Write a program to Invoke the Browser with specified URL

systemutil.Run "iexplore.exe", www.naukri.com

Write a program to find whether image contains tool tip

msgbox Browser("Naukri.com - Search Jobs").Page("Google Image Result for").Image("See full size image").GetROProperty("alt")

Invoke the Browser with specified URL

Invokeapplication “C:\Programfiles\Internet Explorer\IEXPLORE.EXE”
Browser(Obj).Enter http://www.google.com

Write a program to Check given text is displayed on the web page

Const Val = "My Nakuri"
a = Browser("Naukri.com - Search Jobs").GetROProperty("title")
If strcomp(a,Val,0) Then
Reporter.ReportEvent micPass,"Browser Title", "Is Equal"
else
Reporter.ReportEvent micFail,"Browser Title", "Is Not Equal"
End If

Verify page title is displayed correctly

Const Val = "My Nakuri"
a = Browser("Naukri.com - Search Jobs").GetROProperty("title")
If strcomp(a,Val,0) Then
Reporter.ReportEvent micPass,"Browser Title", "Is Equal"
else
Reporter.ReportEvent micFail,"Browser Title", "Is Not Equal"
End If

Write a program to refresh a web page

Browser(Obj).Refresh

Print URL displayed in the address bar

Furl = Browser(Obj).GetRoPerperty(“OpenURL”)
Msgbox Furl
(OR)
a= Browser("Naukri.com - Search Jobs").Page("My Naukri_3").Object.links
msgbox a
a= Browser("Naukri.com - Search Jobs").Page("My Naukri_3").Object.url
msgbox a

Find image width and Height

fwid = Browser(Obj).Page(Obj).Image(Obj).GetRoPerperty(“Width”)
fhig = Browser(Obj).Page(Obj).Image(Obj).GetRoPerperty(“Height”)
(OR)
msgbox Window("Flight Reservation").WinRadioButton("Business").GetROProperty("width")
msgbox Window("Flight Reservation").WinRadioButton("Business").GetROProperty("height")

Program to check whether given link exists

IF (Browser(Obj).Page(Obj).Link(Obj).Exists) then
Report.reportevent “Link Exists in the Page”
Else
Report.reportevent “Link not Exists in the Page”
End if

Write a program to select all the Radio button

Set ODecButton = Description.Create()
ODecButton("Class Name").value = "WinRadioButton"
Set butcnt = Window("Flight Reservation").ChildObjects(ODecButton)
nobutcnt = butcnt.count()
msgbox nobutcnt
For i=0 to nobutcnt -1 step 1
butcnt(i).set
Next

Capture web button image

Browser(Obj).Page(Obj).Webbutton(Obj).Capturbitmap “C:\Test\Webbuttonimage.bmp”,True
(OR)
window("Flight Reservation").WinButton("FLIGHT").CaptureBitmap "C:\buttonimage.bmp",True

Write a program to Capture Desktop Screen shot

‘ Minimize the all the window and will show desktop
SystemUtil.Run "C:\Documents and Settings\MDV\Application Data\Microsoft\Internet Explorer\Quick Launch\Show Desktop.scf","","","open"
Desktop.CaptureBitmap("C:\rr1.bmp")

Check default selection in a list box

Comboval = window("Flight Reservation").WinComboBox("Fly From:").GetItem(0)
If (comboval = null) Then
Reporter.ReportEvent 0,"Combo box"," have Default Value"
else
Reporter.ReportEvent 1,"Combo box"," Not Null "
End If

Program to check whether edit box is focused

IF ( Browser(Obj).Page(Obj).Webedit(Obj).Fireevent (“Onmouseover”) then
Msgbox “ Web edit is focused”
Else
Msgbox “ Web edit is not focused”
End if
(OR)
ChkEd = Dialog("Login").WinEdit("Agent Name:").GetROProperty("enabled","visiable")
IF(ChkEd = True) then
Reporter.ReportEvent micPass,"Agent Name Edit Button", "Object is Visiable and Enabled"
else
Reporter.ReportEvent micPass,"Agent Name Edit Button", " Object is not Visiable and Enabled"
End if

Program to check whether edit box is enabled or writable

MyString = Browser(Obj).Page(Obj).WebEdit(Obj).GetRoPerperty(“Visible)
IF (MyString = 1 or True) then
Msgbox & “ WedEdit is Visible: “ & Mystring
Else
Msgbox & “ WedEdit is not visible: “ & Mystring
End if

Write a program to Read items on a desktop

‘ Minimize the all the window and will show desktop –
SystemUtil.Run "C:\Documents and Settings\MDV\Application Data\Microsoft\Internet Explorer\Quick Launch\Show Desktop.scf","","","open"
a= window("regexpwndtitle:=Program Manager").WinListView("object class:=SysListView32" ).GetROProperty("all items")
msgbox a
For i =0 to 10
myarray = split(a)
'msgbox myarray
b= trim(myarray(i))
msgbox b
next

Write a Program to Read items in a Combo Box

For i=1 to Lists-1
Lists =window("regexpwndtitle:=Flight Reservation").WinComboBox("attached text:=Fly From:").GetItem(i)
msgbox lists
if (Lists = Null) Then
Exit for
End if
Next

Write a program to find the x and y coordinates of a button

Dim MyReturn,MyReturn1
MyReturn = Browser(Obj).GetRoPerperty(“X”)
Msgbox Myreturn
MyReturn1 = Browser(Obj).GetRoPerperty(“Y”)
Msgbox MyReturn1