AUTOMATION
1) Perform an activity or a task with a help of software (or) tools is called automation.
2) To perform automation we have to develop the automation scripts, the script can be developed using C, C++, JAVA, .NET, VB SCRIPT, JAVASCRIPT ETC.,
3) For automation testers to develop automation programmer we can use tools and develop the scripting easily.
Automation Advantages
1) Test execution is completed faster.
2) Testing cost is reduced.
3) Consistency and effectiveness of testing.
4) Reusability of scripting across other application.
5) Reusability of script.
Criteria for Automation (when we use Automation)
1) Manual is taking more time.
2) Multiple releases are expected.
3) The tool supports for our application.
4) Customers approvals based on cost, business advantages, budget Etc.,
5) The application is stable.
QTP 10.00
Version Year
6.0
7.0
8.0 2004
8.2 2005
9.0 2006
9.1
9.2 2007
9.5 2008
10.00 2009
11.00 2010
1) The tool is used for functional and regression testing.
2) The tool supports to do automation of both windows and web application.
3) QTP supports to install only on windows OS (XP, 2000, Vista, Win 7)
4) To do automation of any application in QTP we can develop the automation scripts using VB SCRIPTS
Win / Web application:
JAVA Power Builder
.net, sliver line Delphi
WPF (windows presentation foundation) Multimedia
VB Adobe, Flex
HTML Visual Age
WEB SERVER Terminal Emulator (for Unix, Main Frames)
ORACLE
SAP (win, web)
People Soft
Add in manager
This is the first window displays is open QTP, IT will display the technologies support by the tool, based on our application technology select the required add in.
Example: - To do Automation of .Net developed application, .Net add in is required, to Automate SAP application SAP add in required.
QTP window:
Test Pane: This window has two views
1) Expert View
2) Keyword View
1. Expert View: - In this window the script generated is displayed.
2. Keyword View: - It displays the objects used in the program, the operation performed on the objects.
OBJECT REPOSITORY
Resources (menu) à object repository
Short cut = Ctrl + R
1) It has the object and its properties.
2) When the script is run it will search from object in the repository, based on the properties It will recognize the object.
3) The object is automatically added in the repository during recording.
4) If required we can manually add the objects in repository.
1) Based on the technology of application the class name of the object.
example
dialog("Login").WinEdit("AgentName:").Set"nagaraju"
dialog("Login").WinEdit("Password:").Set"mercury"
dialog("Login").WinButton("OK").Click
Compare the count of values from fly from and fly to
(first add the values in repository and write the code)
A)
dialog("Login").WinEdit("Agent Name:").Set"nagaraju"
dialog("Login").WinEdit("Password:").Set"mercury"
dialog("Login").WinButton("OK").Click
x=window("FR").WinComboBox("Fly From:").GetItemsCount
y=window("FR").WinComboBox("Fly To:").GetItemsCount
If x=y Then
msgbox"count is same"
else
msgbox"count is not equal"
End If
5) To open an application.
Systemutil.Run (systemutil= object, Run= Method)
Use this method to open any application or file.
Systemutil.Run “path”
We can open any win/web application.
Example: -
Systemutil.Run “notepad.exe”
Systemutil.Run “e:\data.xls”
Systemutil.Run “e:\games\dave.exe”
6) Invokeapplication “ ”
Use this function to open any application
Invokeapplication "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe "
invokeapplication ”C:\Program Files\Microsoft Office\Office12\WINWORD.exe e:\data.doc”
7) Close the application:
systemutil.CloseProcessByName "notepad.exe" (Check these names in task manager)
VB SCRIPT
1) It is a scripting language developed by Micro Soft.
2) It was introduced to develop web application.
3) It is similar like Visual Basic.
4) It is not a case sensitive language.
Data Types
Specifies the type of data stored in the system like characters, numbers, data, Boolean (T or F) Etc,
In VB script there is only one data type called variant based on the one data type it will automatically understand the data type.
Variant a=10 number
A=”10” string
Variables
àVariables are used for storming same values in the memory during run time.
àThese variables are variable only during execution time.
To declare the variables
Dim X, Y, Z (X, Y, Z are variables)
X=10
Y=5
Z=”abc”
Note: Declaring of variables is optional.
To declare the variables compulsory use the statement
Optional explicit
Script 1
Dim X
X=10
Msgbox “The value is”&X
OP) The value is 10
Script 2
Accept 2 numbers and display all the calculations
Dim a, b
A= inputbox (“Enter a number”)
B= inputbox (“Enter a number”)
Msgbox cint(a)+cint(b)
Msgbox a-b
Msgbox a/b
Msgbox a mod b
Msgbox a^b
__________________________________________________________________________________
Inputbox -------------------------- To accept data from the user
Msgbox --------------------------- To display a message
Convert functions – to convert from one data type to another datatype
Cint ---------------- Covert to integer
Cdbl --------------- Convert to double
Cdata -------------- Convert to string
Cbool -------------- Convert to Boolean
Cbyte -------------- Convert to byte
Note by default ‘+’ takes concant value
Script 3
Change the values from a to b and b to a
A=6
B=10
C=A
A=B
B=C
Msgbox a&” “&b
OP) 10 6
Conditional Statements:
We can use conditional statements for comparison
1)
If condition (true)
-----
-----
End if
2)
If Condition Then
------
------
Else
------
------
Else if
3)
If Condition then
-----
-----
Else if condition then
-----
-----
Else if condition then
-----
-----
Else
-----
-----
Else if
Prg) Accept a number and display it is even or odd number
Dim n
n=inputbox("Enter a number")
If n mod 2 =0 Then
Msgbox "It is even number"
else
Msgbox"It is odd number"
End If
ANCII: American Standard Code for Information Interchange
Starts from 0 – 255
A – 65 a – 97 0 – 48
B – 66 b – 98 1 – 49
C – 67 c – 99 2 – 50
-- -- --
-- -- --
Z – 90 z – 122 9 – 97
These are some of the examples in VB SCRIPT
1)
Dim x
x=inputbox("Enter any number or string")
msgbox"you enterd is "&x
2) Accept 3 numbers and display the biggest number
Dim a,b,c
a=inputbox("enter a number")
b=inputbox("enter b number")
c=inputbox("enter c number")
If a>b and a>c Then
msgbox"a is the biggest number"
elseif b>a and b>c then
msgbox"b is the biggest number"
else
msgbox"c is the biggest number"
End If
3) Accept 3 numbers and display the biggest number
Dim a,b,c
a=inputbox("enter a number")
b=inputbox("enter b number")
c=inputbox("enter c number")
If a<c and a<b Then
msgbox"a is the smallest number"
elseif b<a and b<c then
msgbox"b is the smallest number"
else
msgbox"c is the smallest number"
End If
4) Enter a year and display the enter year is leap year are not
Dim a
a=inputbox("enter a year")
If a mod 4 = 0 Then
msgbox"it is leap year"
else
msgbox"it is not a leapyear"
End If
5) Enter a number and find the grade
Dim m
m=inputbox("enter mark to find grade")
If m>=35 and m<=45 Then
msgbox"third class"
elseif m>46 and m<=65 then
msgbox"second class"
elseif m>66 and m<=75 then
msgbox"First class"
elseif m>75 and m<=100 then
msgbox"Distinction"
else
msgbox"Fail"
End if
6, verify the login application
systemutil.Run"C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
dialog("Login").WinEdit("Agent Name:").Set"nagaraju"
dialog("Login").WinEdit("Password:").Set"mercury"
dialog("Login").WinButton("OK").Click
If window("FR").Exist Then
Reporter.ReportEvent o,"login","windows present"
else
dialog("Login").CaptureBitmap"naga.bmp"
reporter.ReportEvent 1,"login","windows not present","naga.bmp"
End If
1, Reporter.ReportEvent Status,”stepname”,”description”,bitmap
Reporter = Object.
ReportEvent = Method.
Status = 0 = Pass, 1= Fail, 2= Done, 3= Working.
Description = what we want to write.
1) Bitmap = It is an image.
Use this method to write the pass or fail messages in the window.
2) Capture Bitmap.
It will capture the screen shot of the window and store the memory.
3) Exists (Property)
Check the object is available or not and written true or false.
Select Case Statement
It is also conditional statement, it can be used as an alternative to multiple if condition
Select Case Variable
Case Val1, Val2, Val3,……….,
-------
Case Val1, Val2, Val3,……….,
-------
Case Val1, Val2, Val3,……….,
-------
Case Else
-------
End select
Syntax for IF Syntax for select case
Dim design Dim desig
desig=”-------” design=”---------”
If design=”Manager” then select case design
------ Case “Manager”
Elseif design=”clerk” then ------------
----- ------------
Elseif design=”cashier” then Case ”Clerk”
------ ------------
Elseif design=”sales” then Case ”Cashier”
----- ------------
Else --------- Case Else
Endif ------------
End select
Examples
1) Accept one character and display it is vowel or not
Dim str
str= lcase(inputbox(“Enter a char”)
select case str
case “a”,”e”,”i”,”o”,”u”
msgbox”It is a vowel”
else
msgbox”It is not a vowel”
end select
2) Msgbox ucase(“this is a sample”)
Op) THIS IS A SAMPLE
3, Accept some number 1-7 and display the day of the week
Dim Week
Week= inputbox(“Enter a number 1-7”)
Select case Week
Case “1” Case “7”
Msgbox ”Sunday” Msgbox ”Saturday”
Case “2” Case Else
Msgbox ”Monday” Msgbox”It is a invalid number”
Case “3” End select
Msgbox ”Tuesday”
Case “4”
Msgbox ”Wednesday”
Case “5”
Msgbox ”Thursday”
Case “6”
Msgbox ”Friday”
Loops Statements
We can write loops statements to execute the same script for multiple iterations.
1) While Conditions
While Condition
------
------
Wend
àThis loop is executed while the condition is satisfied.
Syntax:
Dim I
I = 1
While I<=10
Print I
I=I+1
Wend
2) Do loop while
Do
-------
-------
Loop while condition
àThis loop is executed while the condition is satisfied but first executes and then checks the condition.
Syntax:
Dim I
I=1
Do
Print I
I=I+1
Loop while I<=10
Dim I Dim I
I=12 I=12
While I<=10 Do
Print I Print I
I=I+1 I=I+1
End loop while I<=10
Out Put Out Put
Nil 12
3) Do loop until Condition
The loop is executed if condition is not satisfied.
Syntax
Dim i
i = 1
Do
Print i
i = i+1
Loop until i > 10
4) For loop statement
For var = value1 to value2 step value
Next
Syntax
Dim I Dim I
For I = 1 to 10 For I = 10 to 1 step-1
Print I Print I
Next Next
Scripts
1) Print the below no up to 100 6) script
Dim a,b,c For I =1 to 5
a =1 s =” ”
b=2 For j = 1 to i
c=a+b s= s&j
Print a Next
Print b Print s
While c <=100 Next
Print c op)
a = b 1
b = c 1 2
c = a+b 1 2 3
wend 1 2 3 4
2) write a table 1 2 3 4 5
Dim n
n= inputbox(“Enter a number”)
For i=1 to 10
print n&” * “&i&” = “&n*i
Next
3) Print in a single line
s=” “
For I = 1 to 10
s= s&i
Next
print s
op) 1 2 3 4 5 6 7 8 9 10
Array’s
àAn array variable is used to store multiple values.
àThe values in the array are accessed using index, the index in the array starts from zero
àThe values in the array = size of array + 1
Ex
| 10 |
| Abc |
| 78.96 |
| 10-10-2000 |
Dim x(3)
x(0)= 10
x(1)= “abc”
x(2)= 78.96
x(3)= “10-10-2000”
print x(1)
Examples
1, 2, 3,
Dim x(3) Dim x(3) Dim x(3)
x(0)= 10 x(0)= 10 x(0)= 10
x(1)= “abc” x(1)= “abc” x(1)= “abc”
x(2)= 78.96 x(2)= 78.96 x(2)= 78.96
x(3)= “10-10-2000” x(3)= “10-10-2000” x(3)= “10-10-2000”
For i = 0 to 3 For i = 0 to ubound For each i in x
Print x(i) Print x(i) Print i
Next Next Next
For each var in collection
--------
Next
Ubound à To get the upper boundary (index) of array
Lbound à To get the lower boundary (index) of array
àTo read all the values from array for each loop is prepared.
àTo read specific range of values for loop is preferred.
Dim = Constant
Redim = To declare dynamic array
Preserve = keep old data in the array when redefined
Example
ReDim a(3)
a(0)=1
a(1)="naga"
a(2)=5
a(3)=6
ReDim preserve a(5)
a(4)=10
a(5)=”10-10-2000”
For i=0 to ubound(a)
print a(i)
Next
Functions:
àA function is a set of statements (or) scripts, functions are collected for reusability of script, we can write function one time, same function is called for many times.
àBy creating functions
(a) Duplication of code is reduced.
(b) Code is reusable
(c) Easy to understand.
There are 2 types of functions
1) Built In Functions
2) User Defined Functions
Built in functions
These functions are already available in VB script
Msgbox, inputbox, Lcase, Ucase, Cint, Cbool, Ctype, Ubound, Lbound, trim, Ltrim, Rtrim, --Etc
Examples
1)
s="this is sample" op
msgbox len(s) 14
msgbox left(s,4) this
msgbox right(s,6) sample
msgbox mid(s,3,5) is is
2) 3)
s="professional" s="professional"
For i=1 to len(s) For i=len(s) to 1 step -1
print mid(s,i,1) print mid(s,i,1)
Next Next
Output check in your system
4) Print only numbers in the given string
s="1dfd2eger3sere4dfewa56ewfwfa789"
For i=1 to len(s)
a=mid(s,i,1)
If asc(a)>=48 and asc(a)<=57 Then
print a
End If
Next
(or)
s="d2er3se4wa5ew6fa789"
For i=1 to len(s)
a=mid(s,i,1)
If isnumeric(a) Then
print a
End If
Next
Isnumeric = Verify the given character is numeric (or) not and it will return true or false
To fine ascii value
Msgbox asc("a")
Msgbox chr(97)
ASC = Get the ASCII value of the given string character Msgbox asc(“a”)
Chr = Get the character equal lent of a given number Masbox chr(97)
Split Function
Split(string,delimiter)
Split the given string at the specific delimiter
Example: 1
S="This is sample" op
a=split(s," ") This
For i=0 to ubound(a) is
Print a(i) sample
next
Example: 2
s="Flight no:1234,Form:hyd,To:bang,class:business,date:10-10-2000"
a=split(s,",")
For i=0 to ubound(a)
b=split(a(i),":")
print b(0)
print b(1)
print "________"
Next
Op)
Example: 3
a=split(s,"@")
For i=0 to ubound(a)
b=split(a(1),".")
print a(0)
print b(0)
print b(1)
Next
Op)
Instr Function
Instr (startpos,string,search)
Search the given word in the string if the word is found it will return the position if it not found written zero
Program
s="This is sample program"
msgbox instr(1,s,"is")
1, write script to count how many times ‘is’ repeated
s="this is sample"
p=1
cnt=0
While instr(p,s,"is")>0
cnt = cnt+1
p=instr(p,s,"is")+2
Wend
Msgbox"This string is repeated "&cnt
Op)
Date Functions
Msgbox date
Msgbox time
Msgbox now
Msgbox dateadd ("d",5,date)
Op)
Note:
We can select all the built in functions from (menu) insert à Step Generator F7
User Defined Functions
àThese functions are created by user, we can call these functions from any test
To create a function
Syntax
Function fname
------
------
End function
àTo execute the function it should be called
Syntax
Call fname
Or
Fname
Programs
1)
Function f1
msgbox"hello"
End Function
call f1
Op)
2)
Function f1(p)
msgbox p
End Function
f1("Testing")
Op)
3) Write a function which accept 2 numbers and return the product
Function f1(a,b)
Dim c
c=a*b
f1=c
End Function
n=f1(6,4)
msgbox n
Note: The function can return only single variable, the value has single value (or) multiple values which is an array
Program
Write multiple values from a function (array)
Function f1(a,b)
Dim c(2)
c(0)=a-b
c(1)=a+b
c(2)=a*b
f1=c
End Function
n=f1(6,3)
For i=0 to 2
print n(i)
Next
Function Library
It is a collection of user defined function, we can call these functions from any test by associating the function library to the test
To create a function library
àOpen notepad, create required functions
àSave the file as file name .Vbs, .qfl, .txt
àTo call functions in the test
File à Settings à Resources à + (add a new file to the list)à Browse (.Vbs file) press ok
Associate .Vbs file during run time
Executefile”e:\funcs.vbs”
Note:
àIf multiple .vbs files are associated to the test, if the same function is available in both .Vbs files then when function is called from the first associate .Vbs file
àWe can also create a function library in QTP file menu à new à Function Library.
Functional Parameters
The parameters to a function can be either by value or by the reference
If we don’t specify default is by reference
Program
Dim a,b
a=5
b=8
Function f1(Byref x,Byval y)
x=100
y=200
End Function
Call f1(a,b)
Msgbox a&" "&b
Op)
Register User defined function to a test Object.
1) The object added in the repository are called Test objects
2) When we are register user defined function to the test object, our own function also displayed in the intelligence
Steps to register in intelligence
a) Open note pad
b) Write the function
c) Register user defined to the test object
d) Save the file as file name.vbs
e) Associate the .vbs file to the test
File à Settings àResources à Add
Note: When the user defined functions created in the test (or) Associate from .vbs file (or) automatically added in step generator
Sub Procedures (or) Sub Routine:
These are also same like function the procedures cannot return a value
Example for function and procedure
Function f1(a,b,c) Sub Procname (a,b,c)
------- -------
------- -------
F1=value/variable End sub
End function
Public (or) Private Functions
a) The scope of function can be either public (or) private
b) The public functions can be called out of .vbs file, private functions are called only in .vbs file
Public/Private function fname(…..)
------------
Fname= value/variable
End function
c) Default is public
Public function f1
Msgbox “Hello”
End function
Call f1
Note: .vbs files can be executed outside QTP also just double click on .vbs file it is executed
Working With External Application
1) Create on object for API
2) Using object call the methods in the API
Dim x
Set x=created object(“API”)
x.methods
--------
--------
I) Scripting.FileSystemObject
This class object provide methods to read and write in the notepad file, perform file operations like Copy, delete etc on any type of file
Example
1) Create a text file
Dim fs,f
Set fs=createobject("Scripting.filesystemobject")
Set f=fs.CreateTextFile("e:\data.txt")
2) How to enter a data in existing file
Dim fs,f
Set fs=createobject("Scripting.filesystemobject")
Set f=fs.CreateTextFile("e:\data1.txt")
f.WriteLine "testing tools"
f.WriteLine"This is sample"
f.Close
3) Read the data from file
Dim fs,f
Set fs=createobject("Scripting.filesystemobject")
Set f=fs.OpenTextFile("e:\data.txt",1)
While f.AtEndOfLine<>true
print f.ReadLine
Wend
f.Close
4) How to add the data for the existing file
Dim fs,f
Set fs=createobject("Scripting.filesystemobject")
Set f=fs.OpenTextFile("e:\data.txt",8)
f.WriteLine "this is new line"
f.WriteLine "this 2nd new line"
f.Close
5) Copy one notepad data from another notepad data
Dim fs,f1,f2
set fs=createobject("scripting.filesystemobject")
Set f1=fs.OpenTextFile("e:\naga1.txt",8)
Set f2=fs.OpenTextFile("e:\naga2.txt",1)
While f2.AtEndOfLine<>True
s=f2.ReadLine
f1.WriteLine s
Wend
6) How to read specific lines from a file
ReDim a(0)
Dim fs,f,i
Set fs=createobject("scripting.filesystemobject")
Set f=fs.OpenTextFile("e:\naga1.txt",1)
i=0
While f.AtEndOfLine<>True
a(i)=f.ReadLine
i=i+1
ReDim preserve a(i)
Wend
f.Close
msgbox a(1)
1) Display the file properties like data created size, type of file, time, Data lost Modified etc
2) Write script to copy a file
3) Display the list of files in a given folder
4) Display the list of drivers in the system
Data Driven Test (Re testing)
Executing the same script with different combinations of input data
1. Create a script to perform 1 transaction
2. Prepare Test Data
3. Parameterize test data to script
Insert different for the data in the notepad file
Dim fs
Set fs=createobject("scripting.filesystemobject")
Set f=fs.OpenTextFile("e:\new.txt",1)
While f.AtEndOfLine<>True
s=f.ReadLine
a=split(s,",")
window("Flight Reservation").WinMenu("Menu").Select"File;New Order"
window("Flight Reservation").ActiveX("MaskEdBox").Type a(0)
window("Flight Reservation").WinComboBox("Fly From:").Select a(1)
window("Flight Reservation").WinComboBox("Fly To:").Select a(2)
window("Flight Reservation").WinButton("FLIGHT").Click
window("Flight Reservation").Dialog("Flights Table").WinList("From").Select 1
window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
window("Flight Reservation").WinEdit("Name:").Set a(3)
window("Flight Reservation").WinRadioButton("Business").Click
window("Flight Reservation").WinButton("Insert Order").Click
Wend
f.Close
Excel Application
Use this API to work with MS Excel files
1) Create MS Excel and write in sheet
Dim xl,wb,ws
Set xl=createobject("Excel.Application")
Set wb=xl.Workbooks.Add
Set ws=wb.Worksheets("sheet1")
ws.cells(1,1)=100
ws.cells(2,1)="abc"
ws.cells(3,1)="naga"
ws.cells(4,1)="78.85"
wb.SaveAs"e:\data.xlsx"
wb.Close
Set xl=nothing
2) Read Data from the Excel File
Dim xl,xb,xs
Set xl=createobject("Excel.Application")
Set wb=xl.Workbooks.Open("e:\data.xls")
Set ws=wb.Worksheets("sheet1")
r=ws.usedrange.row.count
c=ws.usedrange.columns.count
For i=1 to r
s=" "
For j=1 to c
s=s&" "&ws.cells(i,j)
Next
print s
Next
wb.Close
Set xl=nothing
3) Verify the login success or not for the MS EXCEL
Dim xl,wb,ws
Set xl=createobject("Excel.Application")
Set wb=xl.Workbooks.Open("e:\nnn.xlsx")
Set ws=wb.Worksheets("sheet1")
For i=2 to 3
ex=ws.cells(i,6)
td=ws.cells(i,9)
a=split(td,",")
systemutil.Run"C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe"
dialog("Login").WinEdit("Agent Name:").Set a(0)
Dialog("Login").WinEdit("Password:").Set a(1)
Dialog("Login").WinButton("OK").Click
If window("Flight Reservation").exist Then
f=1
window("Flight Reservation").Close
else
f=0
dialog("Login").Dialog("Flight
Reservations").WinButton("OK").Click
dialog("Login").Close
End If
if(f=1 and ex="Login")or(f=0 and ex="Error") then
ws.cells(i,7)="Expected and same"
ws.cells(i,8)="passed"
else
ws.cells(i,7)="Expected and actual are not same"
ws.cells(i,8)="Failed"
end if
Next
wb.Save
wb.Close
Set xl=nothing
3) Display the colors
Dim xl
Set xl=createObject("Excel.Application")
xl.Visible=true
xl.Workbooks.Add
For i=1 to 56
xl.Cells(i,1).value=i
xl.Cells(i,1).interior.colorindex=i
Next
4) Write data in to Excel and format the excel
Dim xl
Set xl=createobject("Excel.Application")
xl.Visible=true
xl.Workbooks.Add
xl.Cells(1,1).value="Name"
xl.Cells(1,2).value="score"
Set r=xl.Range("A1","B1")
r.Font.Bold=true
r.Interior.ColorIndex=3
r.Font.ColorIndex=2
xl.Cells(2,1).value="chadalavada nagaraju"
xl.Cells(2,2).value="80"
xl.Cells(3,1).value="naga"
xl.Cells(3,2).value="70"
xl.Cells(4,1).value="raju"
xl.Cells(4,2).value="60"
Set r=xl.Range("A2","B4")
r.Font.Size=14
Set r=xl.Range("A2","B4")
r.Interior.ColorIndex=4
Set r=xl.ActiveCell.EntireColumn
r.AutoFit()
Word Application
This API provide methods to work with MSWORD
Example 1
Dim ms
Set ms=createobject("Word.Application")
ms.WordBasic.filenew
ms.WordBasic.insert"This is sample data"
ms.ActiveDocument.SaveAs"e:\111.docx"
ms.ActiveDocument.Close
ms.Quit
Set ms=nothing
Internet Application
XML (Extensible Markup Language)
Working with .net frame Work (or) library
àThe VB script can be has limitations the programs can be developed in .net, these library we can call from QTP
This features is provided from QTP 9.2 on words
Syntax
Dim d
Set d=DotnetFactory.createInstance(“n1.cl”,”e:\sample.dll”)
d.f1()
----
Note: To perform this programming .net addin is not required
Example: 1
Dim d
Set d=DotnetFactory.CreateInstance("system.windows.forms.form")
d.test="sample From"
d.show
2) Write the data in to text file
àHow to recognize non standard objects (or) Custom objects
The object which are understood by the tool are called ‘standard objects’
The objects are not understand by tool are called ‘non-standard objects’
Note: - By seeing the application we don’t know which are non-standard objects, try recording
If tool is not understanding the object we can try the below options
1) Send keyboard events (send keys)
2) Analog Recording
3) Low level recording
4) Virtual objects
5) User mercury. Device Replay API
6) Create a library in .net and call
1. Send Keys:
We can send keyboard events to the application and perform the action on the application to work with this we can use
Wscript.shellclass
Dim ws
Set ws=createobject("wscript.shell")
ws.Run"notepad.exe"
ws.SendKeys"This is sample"
ws.SendKeys"^+s"
ws.SendKeys"{ENTER}"
ws.SendKeys"%{F4}"
wscript.shellclass also provide methods to work with the register like write, read, delete
2) Analog Recording
We can use this recording to exactly record the mouse, to perform keyboard events and if tool does not understand the object on that object we can do analog record
Note: In analog record for any no. of number of actions in the application only one line statement is generated
Syntax:
-------------object (“objectname”).RunAnalog”track no”
Navigation
Start Recordà Automation (Menu)àAnalog Recording
Show the hand Icon and click on a application à(click) start analog record (button)
Automation (menu)àAnalog recording for both selecting and unselect menu.
3) Low level Recording
If object is not understood during recording, we can use low level recording.
Navigation:
Start recordàAutomation (menu) à low level Record
4) Virtual Objects
We can use virtual objects to convert selected area in our application to a similar type of standard object so that recording can be done successfully on that object
Navigation:
Nextàclass : buttonàMark Object (click on mark object) ànext (select the parent object)àname (enter the button name)àfinish.
1) To display the list of the virtual objects
Tools (menu)à Virtual Object à Virtual Object Manager
2) The virtual object created or stored in
C:\Program Files\HP\QuickTest Professional\dat\VoTemplet
Filename.vot (Virtual object Template)
3) To disable the recognition of virtual object during recording.
Tools àoptions à General à Disable recognition of virtual object while recording
Outlook Application
We can use this API to work with MS outlook send mails, check the mails etc
1) Send a new mail using out look