You are on page 1of 128

;Mx: liveTech

twdt;7~s~·

r:
I'!
\j
Course Material
'1.1
·I . .,
'

,.
1

' i-

.~r-
'L___
j::,_
~

[
1. _

p
~-----­
~
i·:
g___
l;
\l
t!;

I~
r-~
~~
~
~~===
~ r -

·.·~ r -
Ib:
Live Tech

Since 2004, LiveTech is involved in training on Software Testing Tools Projects for over 8
i
I
years. It was established with a motive to promote software testing practice and competency by I

providing training to aspirants seeking career in software testing. It is the first Institute of its kind
that started Project Testing in Hyderabad. Since 2004 LiveTech has successfully skilled 50000+ 'f--
professionals in Software Testing.

LiveTech is a· leader in creating not only skilled professionals but also enhance their
employability through real time project implementation training in Software Testing. The
programs are designed by industry experts and backed by certifications recognized globally.

Mr. Venkataramana Reddy- Faculty


Currently working as a Sr. Test Manager with SEI CMMI Level 5 Company and having 12+
Years of Genuine experience in Software Testing. Mr.Venkat handled 300+ batches and trained
40,000+ Professionals from last 8 Yrs in LiveTech.The very first faculty to start of its kind
Project Testing in Hyderabad. He is Founder and Director of LiveTech.

Testing Tools with Project


(Functional Test Engineer Program)

Module 1: Software Engineer Foundation Program


Module 2: Real Time Manual Testing - Test Design
Module 3: Testing Environment - URL
Module 4: Project Testing- Test Execution

Module 1: Software Engineer Foundation Program


1. Introduction to Software Testing
2. SDLC phases and Deliverables
3. SDLC Models
4. Software Engineering
5. Software Process and benefits
6. SEI CMMI Levels
7. Software Configuration Managemen:- VSS
8. SQA and SQC and Verification and Validation
9. Testing Roles and Responsilities
i_"_
Module 2: Real Time Manual Testing (Test Design)
1. Project Management Plan
2. Requirement Specifications
3. Test Plan
4. Test Scenarios
5. Test Cases
6. Checklist for; Web application testing

Mr.Venkat (Sr. Test Manager) Page 1 of 118


,-.-
L-
~LiveTech 6!'tfyttstiiJOS<JfBri<>DJ
~
Module 3: Testing Environment (URLl
1. Project and Product
2. MVC Architectures
3. Environments and Servers L
I
4. Project Architecture

Module 4: Project Testing (Test Execution)


1. Builds from Development to Testing
2. Text cases Execution
3. Defect Reporting
'""' 4. Working with Track+ I Bugzilla
5. Severity and Priority
6. Defect life cycle
7. Re-testing and Regression testing
8. Project Workflow
9. Requirements Traceability Matrix
10. Testing Process
11. Database Testing using Toad
12. Automation using HP QTP
13. Automation Frameworks Implementation
1. Linear Framework
2. Modular Framework
3. Data Driven Framework
4. Keyword Driven Framework
J
~

5. Hybrid Framework r
~
~
14. Test Management using HP Quality Center
1. Site Administrator Job I
~
2. Quality Center Users Job ~
~
~~

"~
__
...
l.i

~1
";

Mr.Venkat (Sr. Test Manager) Page 2 of 118


Automation Testing Process

In my current project Automation Testing Process started with three Stages

-Stage 1
1. Tool Evaluation

2. Analyzing the Test cases


3. Preparing Analysis sheet
4. Estimating script development time -Stage 2
5. Sending summary sheet for Approval
6. Confirmation

7. Automation Folder Structure Preparing


I
8. Preparing Object Repository
9. Creating re-usable components and functions
10. Creating scripts and Enhancing scripts
-Stage 3
11. Dry run
12. Final Execution
13. Peer Execution
14. Delivery of scripts
15. Enhancements

;_:.._

,-.-

,-,-

Page 3 of 118 a .
Mr.Venkat (Sr. Test Manager) ~
fi
For developing Automation Scripts and framework we need to know below Concepts:
I. Retesting and Regression testing
2. Test Automation fundamentals
3. Automation Testing Tools
4. Recording and Run modes
5. Object Oriented Programming
1--
> Object Repository - (Folder I)
6. Descriptive Programming
7. Synchronization
8. VB Script
> Conditional Statements
> Built-In functions
> User defined functions -(Folder 2)
> QTP Sample Script with Template
9. Data Driven Testing- Parameterization
I. Data Table -(Folder 3)
2. Environment -(Folder 4)
3. Random Number
4. Data base
5. Text files
6. Excel files
I 0. Actions
11. Checkpoints
12. Recovery Scenarios -(Folder 5)
13. QuickTest Script Editor
14. Test Batch Runner
15. Automation Object Model (AOM) -(Folder 6)
16. Web Programming (Web Scripts Development) -(Folder 7)
17. Test Results and Test Log -(Folder 8)
18. Automation Frameworks Implementation
I. Linear Framework ,,
-~-
2. Modular Framework
3. Data Driven Framework
4. Keyword Driven Framework
5. Hybrid Framework
19. HP Quality Center- Test Management
1. Site Administrator Job
2. Quality Center Users Job
51 ~~:a e-t:P~~e .,
D Environment
f!Jl Library
~::;;3 Recovery
~ Repository
~3 Test Dat-3
ell TestLoQ .
~Test.Run
20. Others fi:i:ll
tes~ script:
-"- -

Mr.Venkat (Sr. Test Manager) Page 4 of 118


.* Livelech
E
Brdj ltstinn scfntio., L
1. Retesting and Regression testing
What is Retesting?
• Retesting of the application to verify whether defects have been fixed or not.
What is Regression testing?
1. It is Re=Execution of some or all test cases of a testing activity for each build to verify
that changes or fixes made have not introduced new errors
2. Regression testing is done in three situations.
1. One is after fixing the bug
2. Second one is if a new change request will come from client.
3. Third one is when Environment changes Ij
Here we have to verify whether already existing functionality can getting defects (or) not.
l
What is "Automated Testing''?
• "Automated Testing" is automating the manual testing process currently in use.
• This requires that a formalized "Manual Testing process" currently exists in your
company.
II
Minimally, such a process includes: 1
I
Detailed test cases, including predictable "expected results". (Test Cases must be
!i

documented)
I
• A standalone Test Environment, including a Test Database, such that the test cases are
able to be repeated each time there are modifications made to the application.
If your current testing process does not include the above points, you are never going to be able
to make any Effective use of an automated test tool.
> The real use and purpose of automated test tools is to automate regression testing.
> This means that you must have or must develop a database of detailed test cases that are
repeatable, and this suite of tests is run every time there is a change to the application to
ensure that the change does not produce unintended consequences (errors).
r An "automated test script" is a program.
> Automated Script development, to be effective, must be subject to the same rules and
standards that are applied to software development.
'r An "automated test Suite" is a database of all detailed Automation Test Cases.

\Vhy we go for Automation?


Probfems in Manual Testing
,- No Reusability
,- More Resources required
> Time con~uming
;.- Budget is high
> Human Errors causes poor quality
> Simultaneous actions are not possible (Parallel)
\Vhat is Automation Testing? ~---

r Tes1ing an application with third Party Software help or Automation Tool is called
Automation Testing. (or)
> Com·erting manual Test cases into Automation Scripts (in form of code) is called
Automation Testing.

Mr.Venkat (Sr. Test Manager) Page 5 of 118 •---- --

i
~
-
Benefits of Automation Testing
> Reusable
> Quality
> Fast
> Reliable
> Repeatable J--
Automated functional testing tools
1. Open Source (FREE Tools)
> Selenium
> Badboy
> Sahi
> Watir
2. Commercial
> HP QTP
> IBM Test partner
> Empirix eTest Suite

Tool Evaluation
In my current project, Automation tool is evaluated based on below project features:
1. Multiple Browser Support
2. Java applications support
3. Ease ofUse
4. Multiple Operating Systems
5. Ajax support
6. Web Applications support
7. UI Tests
8. Scripting
9. Record and Play back
10. Object recognition capability
11. Data driven testing
12. Customization of recorded code as per our requirements
13. Synchronization issues
.14. Test suite creation
15. Ivlaintenance of scripts when features modified
16. Central Object Repository
17. APls availability
18. Database verification
19. Vend or support
20. Frameworks Creation
21. Tool Performance r--
• Based on initial evaluation on above Project scenarios, the above information is captured.
• QTP and Selenium tools are finalized after evaluation other tools from both commercial and
open source.
• Client/Management is finalized QTP Tool to automate my Current Project.

Mr.Venkat (Sr. Test Manager) Page 6 of 118 '


~
~-

~
w
Introduction to HP QTP
~ Initially developed by Mercury Interactive Corporation
~ Mercury Interactive is acquired by HP (Hewlett-Packard)
~ HP Commercial Product
~ Functional Testing Tool
~ Used for Regression Testing
~ A vail able in various versions like
• 11.0- Released in 2010
• 10.0 - Released in 2009
• 9.5 - Released in 2008
• 9.2- Released in 2007
• 9.0- Released in 2006
• 8.2 - Released in 2005
• 8.0- Released in 2004
• 7.0- Never released.
• 6.5 - Released in 2003
• 6.0 -Released in 2002
• 5.5 - First release. Released in 2001
~ It supports Functional Testing of all popular environments, including Windows, Web, .Net,
Visual Basic, ActiveX, Java, SAP, Siebel, Oracle Applications, PeopleSoft and Mainframe
Application Technologies
~ It supports 100% dynamic testing.

Introduction to Quick Test Process

Quick Test testing process consists of 7 main phases


1. Preparing to record
• Test Environment
• Test Conditions (Regression Test Cases)
2. Recording a session on your application
• Navigate according to Test Conditions
• Execute Regression Test Cases
3. Enhancing your test
• Parameterization
• Adding logic and conditional statements
• Inserting checkpoints
4. Debugging your test
• Check that it operates smoothly and without interruption.
5. Run Test
• Check the behavior of your application
6. Analyzing the test results
7. Reporting defects using Tracking tool (Quality Center I 0.0/Bugzilla 3.2)

Mr.Venkat (Sr. Test Manager) Page? ofll8 ~


i~-

~
-* liveTech
· · fUctFj llSii•g sofzlto»u

QTP - Licenses
Two types oflicenses
1. Seat License -Single User
2. Concurrent License -Multiple Users
1. Seat License
A permanent seat license that is specific to the computer on which it is installed.
2. Concurrent License
A network-based concurrent license that can be used by multiple QuickTest users.

Add-in Manager

Default Add-ins
• ActiveX
• Visual Basic
I
• Web
Available Add-ins
• Java
• .·Net
• SAP
• etc: ..

Title bar
Menu bar

Toolbars

Document
tabs

Test Flow
pane

~<eyv~•ord
View

Expert
View tab

Data Table - - - ; ! - - - - - - - - -

Mr.Venkat (Sr. Test Manager)


._-_
~

Page 8 of 118 r--


~
QTP Main window is divided into mainly 8 parts
1. Menu Bar
2. Toolbars
3. Test Flow Pane
4. Test Pane
4.1 Expert View
4.2 Keyword View
5. Data Table
6. Active Screen
7. Debug Viewer
8. Missing Resources Pane
1. Menu Bar
Displays menus of Quick Test commands.(File, Edit, View, Insert, Automation etc.,)
2. Toolbars
Displays Icons/images for all Quick Test commands or submenus
3. Test Flow Pane
Displays the hierarchy of actions and action calls in the current test, and shows the order in
which they are run.
4.0 Test Pane
4.1 Expert View:
In the Expert View, Quick Test displays each step as a VBScript line or statement.
1. Web Application
1.1 Object's description --- Displayed in parentheses and Case Sensitive.
Browser ("Google")
1.2 Object hierarchy---- Separated by a dot.
Browser ("Google").Page ("Google").WebEdit("q")
Ig-
Operation or method--- Always displayed at the end of the statement, followed il
~-----·--

by any values associated with the operation. 1


Browser("Google").Page("Google").WebEdit("q").Set "Venkat" i
2. Desktop I Windows Application i
~
Dialog ("Login'').WinEdit("Agent Name:").Set "admin"
~
Window ("Flight Reservation"). WinButton("FLIGHT").click
4.2 Keyword View
In the Keyword View, Quick Test displays information about each step and shows the object
hierarch in an icon-based table.
"""'
;;;:iiii•::-&rJi.i'fC·•:;;;:;;·:c-:
,c~l,;~~~,~s{~~fi:~;ttb~t§fii~~ki%;0f:'(t;;;~~~s~2.rfi.~> ··11:;;&r:+tii10\i?1'l'z.it1HA~~~1~!l~~;t~~~J:~t'11'%0frL~';ii.%it.'01£1~~; .
f·+ii!~~F:;;;~:;~·~~~$~1[~~;::::Ejil~::a~
i~Wl/g:~~]tl~~*~ii,;iiif~~~"@.-~.·:~.'fF.jfki~.:~w&t~*4t~w;~;t~"R~f~Ji~ltitm"~J::~~••(i•~
jType :rnicT.o:b :T>tpemicT~inlhe''Mask.EdBox"ActiveXobiecl ·
1~?S:Jt~Jt~~tt"f:1{~i,i~~;;;&1f~\,,·~,_;<-A~tw;rt~~-t:t:~--::~;,!~:~~~f~~~::!~:t~~~,:~~~~~:~\~~£.1li~~tis
)Select ;•t.osAngeSes" ;Se&ectlhe '\.as Angeles:" item hom the "Fly TO:" bl
-~-~~:1-~>:~£:tt~i~ltt~~:~:~::r~~ftfit~~~4t:r -~i',~\~~+lm~;~~-~-~i~l&~ift~~:tt~=~-~~~1¢/i~ttqf;tv;~}:r~m~~-?&l~JB::\:
·Click . ; C'cl< the "FUGHT" WI on
<.'r}£~-::mt1fl~(~{tf-~:~f:;~}1S~;~J}?.k~i'§i i - 1-·~ttft.Y:"S)idf~:~2;i;Jfnilt~~~%i~hit~~t\~~f~?~:i;;;._-_ ,:<-~;1J0ilf\~~s~;1SJ>~t:&;~;.~,;;:~;2Zi}k~it~;~i ~~!;:_,
; Set :"mefcu-y" i Erl:er ''mere...y" ~the ''N.ome:" edit box.
Chck ~ ' Chck the "ln~erl Order" butron

:;- -

Mr.Venkat (Sr. Test Manager) Page 9 of 118 , --


~=--===-=
£-·- -

~
5. Data Table
} It is used to store the data and parameterize that data to the test script
} There are two Sheets by default. They are
(1) Global
(2) Action!
} In one data table we will have 256 Sheets. Out of 256 sheets, one sheet is Global and
t----
remaining 255 sheets are Action Sheets
} Global Sheet related to all the tests.
} . Action Sheet related to co~-~~p()pdin,.g; Acti()n OD,:ly~

6. Active Screen
Provides a snapshot of your application as it appeare~ when you performed a certain step during
the recording session.
Advantages:
} Easy to insert Check Points I Output values.
} Easy to add objects to all object repository.
} Easy to insert steps.
} Easy to understand script by observing images in active screen area.
7. Debug Viewer
} It is used for viewing, modifying or setting the current values of variables or objects during
Test execution break with the help of three tabs--- Watch, Variables and Command
:,,
8. Missing Resources Pane
; i;
} Whenever we open a test, the files which are associated with that test are missed I moved then
Missing Resources Pane will be opened automatically and displays the information about that
missed file.
} The Missing Resources pane may list any of the following types of missing resources:
• Missing Action Name
• ~vfissing Object Repository
•. Repository Parameters
• Missing Environment Variable
• Missing Library

Unmapped parameter values


From test: C:\Prograrn FileslMercury lnteractive\QuickTest -
~---

:=----=--:----
'-
Mr.Venkat (Sr. Test Manager) Page 10 of 118 ~
~
~
Object Oriented Programming
Class:
>- A class is a blueprint or prototype from which objects are created.
>- It's an abstract idea of something. ~----
>- Class contains data members and member functions.

Object:
>-
Object is an instance of a class.
Example:
> Here person is a class which contains various attributes like Name, age, color, gender, height etc.,
> Each object contains their own values for abcve attributes.
> Objects are a representation of every item found in an application
> Objects (e.g. Button, Textbox) are elements within an application.
>- Each object has the following elements
Properties, Methods & Events
> Objects are referenced in code using dot notation
objectName.Method()
1. Properties
> These are characteristics of the object
Ex: the text on a button. QTP uses this to recognize the object

2. Methods
> These are built in functionality of the object.
> The VB Script code that we write (or record) actually makes calls to the methods of an object
Ex:
Reporter.ReportEvent()
Here ReportEvent is the method of the Reporter object.

3. Events
> These are what can be done to an object. This is used by programmers to determine what an
object does in response to an action you perform. It is however unused in QTP.

·Understanding QTP Script

Windows EnVIronment Classes and Objects

S.No Window I Obiect Class/Script


1 Main Window Window("Window Name")
2 Sub Window Dialog ("Dialog Name")
3 WinEdit("EditBox Name")
4 vOffib 0 B OX
ro. jcombol :3:
, ............... . WinComboBox("ComboBox Name")
5 . Menu WinMenu("Menu") -

6 Radio Button " ~;~ Button WinRadioButton("Radio Button Name")


E-
7 WinCheckBox("Check Box Name")
8 WinButton("Button Name")

=
'
Mr.Venkat (Sr. Test Manager) Page 11 of 118
~
~
Web Environment Classes and Objects

S.No Web I Ob.iect Class/Script


1 !Browser Browser("Browser Name")
2 Page Page ("Page Name")
3 Frame Frame("Frame Name")
4 wink Link("Link Name")
5 ~dit Box WebEdit("EditBox Name")
6 !List Box WebList("List Box Name")
7 Menu WebMenu("Menu")
8 Radio Button WebRadioButton("Radio Button Name")
9 CheckBox WebCheckBox("Check Box Name")
10 Button WebButton("Button Name")

Operation and Scripts

S.No Operations Script


1 !Active Window .Activate
2 ~nter Text in Edit Box .Set "Text"
3 Select Item from the List box .Select "Item Name"
4 Select item from the Menu .Select "Menu Name;Item Name"
5 Check on or off the Radio Button./ .Set
6 Check on or off the Check Box .Set "On/Off'
7 Press on Push Button .Click
8 Enter Password in Edit Box .SetSecure "Encrypted Text"
9 Close Desktop application .Close
10 Close Web application .Closealltabs

QTP Script Syntax


\
1. Windows Based
In which window.On what object.What operation is done.
Syntax: ·
Window("Window_Name").Object("Object_Name").Operation/Method.
r----
2. WebBased
In which browser.in which page.on what object.what operntion is done. (or)
In which browser.in wl">..ich page.in w}ljch frame.on what 0bject.what operation is done.
Syntax:
Browser("Browser_Name").Page("Page_Name").Object( ·object_Name"). Operation/Method.

F
~
Mr.Venkat (Sr. Test Manager) Page 12 of 118 Q-.-

~
~
I==
E
Sample scripts for windows application

Test Scenario 1:
1. Activate window , . ,
2 Enter Agent Name as' admm1 , I
3: Enter Password as "mercury" ~-

Click on

Script .
I
-15'ialog("Login").Actlvate , . ,
Dialo "Login").WinEdit("Agent Name:").~;t adllli?, 1
D ..I g(("Login").WinEdit("Password:").Set mercury
Ia og ·
Dialog("Login").WmButton( "OK") .Cl"lC k

·Test Scenario 2:
1 Activate window ,
2. Enter Employee Name as "Appa Rao
3. Select Employee No. as EOOI
4: Enter Employee Salary as 10000
5. Click on [Submit]

.··E~fl~-:~·~:m•••.·····,•,•,•••

;=~rl 1;. ...:..=':,.-··_.· ·"'-·__.___


·····••><>· .··s~_i'j'> >··········
_

Script: ·


1-J ;ndoo.J (_\I Er11 pl~ ee o~·/0 ') . AcJi'vote..
w;~do 0 ( " te.,r l~ee. ~ ,.,.,e ,") · sci ''.tr Pa /Ca o
oetru'l.s ':) • IJ; n edo'l (_ " eropl ee N 1 •

0-e:i-oJ't.s ':J · ~v;•~ L" t:...,l~ee No · ::F·sek " E oa


Cc..thbc~
IJiV!J,w (" t:"'PI<?:Jee
·
" 1--
-.-

(" t=..pt~e veJ..,,ifs ':J,


1
tv•'h bw tJ;.,u,'t (_ "&-plrq>e s.,J'?:Y : J ..s-et

=
Mr.Venkat (Sr. Test Manager) Page 13 of 118
~
~
Test Scenario 3:
I. Activate Window.
2. Enter Patient Name as "Abc"
3. Select Ward No. as "I7" . ,
4. Select Referral Doctor as "Dr.Armth
s. Select Cough Radio Button ON
6. Bill Check Box ON
7. Click on [Ok]
8. Enter X-Ray cost as "200"
9. Enter Blood Test as "300"
I o. Enter Bed Bill as "500"
Il. Click on
...!
' X-Ray.
: Blood Test
:' BedBill:
'
I

''
Ok
I

Test Scenario 4:

it--
~ Click on [Ok] '
Script:

u;nd.,._, ( '' Ml mp t E- :;J ·oicc!~ ( ''.s~ mpLE- -t '). D,'a.J.~J ( " .s A-mpl <" - <. :) ·
:=-------=--=-----
~
Mr.Venkat (Sr. Test Manager) Page 14 of 11 8 r---
L__
~. l-JVeTech fil'tryUslilgs.kti.Ja•

Sam~le scripts for a web application


Test Scenario 1: .
1. Open LiveHRMS stte" "
2 Enter Login Name as rahul
3: Enter Password as "rahul"
4. Click on [Login] ,
5. Click on 'Logout
6. Close browser

Script: · ~ · , /·
s~ s~ cth' I• ~4_)} \\ ,·exp lure~ !I http: II (,\JWW. Lt o-€ ftC . (0' I/' h 'IY)S iJ

r., Y<WMx ( ' Li ll't H ~ M.S -


1
HUVJCUJ R-e.> un e j. p "'jE ( " Lo'v·e Hr<. "lS - li vo. " l1a.t <>m:t
· Nf!ht:d-'.'t( 11 txruS'€/N"o.J"fle ' 1)·s-u:: n~l
,, t"/
- iNe.b t-d..lt (_ l l f >d:Po.dSWc-Yd. i'J. ~cl-' 1
,, J; ~I',

,, I)
. ~I?Lt+-kn (1' LV<[l'n 11J. ~·c_l_c__

• ut...k._ (_ l L LC[J CLt t- 11j · C)..J 'c.)c._


I )

Test Scenario~: , . f d . Login of current Project.


Verify Functionality o a mm
I. O~Y) EfZPP'r0(_ +1-pp/.t'co.h'Cir) .
.2. · EWe.v CLtS+arrer U.ser- d 08 11 Pmc u
3· t'c.Jev fb$~Yd OV tt Pft1c 11
4 · clJcK 0! [ S\.t br..J t]

5· clic.l 0! , 1 G:L1 Prob~ t-e '


-6· Sa.fe.d- t:J pe_ oo tl ~'ce_JJ to cp~
~ · cJ..iu.. CYJ Cstt!:A.ti:J
S · c)_; c1<_ <11') , ~ c.uJ 1 .

q· c l o5'€. M-e t3 rc.I..tll'-e,r


pmc. If'J!::J ~--

l.\S0Jel
pa..s.su..l:ll:l
=
SllbN'.t- L---
8 Mr.Venkat (Sr. est Manager) L_
~ tivez,a.nl!~
sus+enJtth I· I<Mh \\ • exp lure~ ll ht+p .'II LocJ ~cJJt .· ~GOo I Er<.p I_; t')

:...:! f \. f" fYJC ,3 0


Sci:0~ ,f,Y = e n:o..xs.c.- l ,, p me.. Inc ''J' P~e (" Prnc 1 h(o ' )

Sci oJ:u l)r I ~ i)~c.oJSe' [ "Pmc J" c · "J · P"':Je (''IJ-ew ~e ::J
1
obJ Bv. !NebccLit ( H US'f'l rd__ 'j . sci II Pmc I)

objDr· tuebt=c:Lt ( l'(J~sw«cl. 11 )· Sel: 11 PMc''


11
6b.ifJr · k.,e,b{3l{·f+VYJ ( tr S<.tl?rw't .)' c_)_,'cl:_

'
''
t1b.i Br 1. F rcuv.-e ( i \ C ru..~,c_ ;J · rLJ ~<- ( lt ~cL.~ prCJlJ<'fe {j . JJ'cJ.r;,__
Obi fJrt · fyC41.o...e. ( q C.. Oe;_~'(s 'j · ~b~ s r l '' p~ f::-.j Pe ") • .S~le c1
II of. f.,(e 'I

cb..18 n · Fro-~v-.e ( \' e_ ~·r.s ")· ~ B!.i++crV} C \ '.s u1 ~- t: ~ . G0J<-.

abJ!n · Fr~ (_ L~ c_n.k.t_ '0 . Lc.._t_ ( 1' L'ZJ CJLtT t:). d<&._

-~ ~"'u.-)sev ( \' Pmc rct c_. '~. CJ o..:;,e A-ll ro-bs


! 'i:: i!'

!:· •.•
i
! t Test Scenario 3:
1 i Verify Google Search.
··• I
Sl:J ,s.~ U Nt.v W· ;] O<(J le · Cu'; ~
11
fi I •iluY) 11

~-rCfuJ.s£¥ ('ljOcjle''.J Pc>je (_' 1 ~ Ooj Je 1



) s~
t....!E.b e-ch't l 1'q; /)J. tr Li ve._-,e-L.VJn t'.I
r

B-vo.;.\S 0- (_ n' 4ofj 1-e 'j . Po:Je l \' 0 CC:_il e ~~). ~% [)>j.}l-a7 c t.r
\I
cJ o J le
1
.s-e.a.~J... El} - b '_ J~
/ · GU <...J'.......

bra..u.Je'fC 1 ~a~Jff J) ·(J~€tl Lue.IE'ch- G_ac(jte !Jec-v~ 1


)· D.u./c_

( '
1
1---eAc~ fa L ,_{!_ T-e cJ, s~fJu.setrEj.. cL' vk_
8----

~f.YV-))Er( '\ Cro~ re c l0 7l' Afl ~~


1'
~
11 _).

'
to...

~· -

=
Mr.Venkat (Sr. Test Manager) Page16of118
~liveTech
Fivtly tulillll soflrtioos

Object Identification

How QTP learns objects in application?


Stores Object as Test Object, Determining the class it fits.
1. Mandatory properties
2. Assistive properties
3. Ordinal identifier
4. Smart Identification

1. Mandatory properties:
While recording, for each test object class, QTP learns a list of mandatory properties to Uniquely
identify the object.

2. Assistive properties:
If not sufficient, QTP adds assistive properties until is has compiled a unique description.

3. Ordinal identifier: .
If no assistive properties are available or if not sufficient, QTP adds a special an ordinal
identifier types as index, location and creation time of the objects are used to create a unique
identification '
4. Smart Identification:
• If Quick Test is unable to find any object that matches the learned object description, or if it
finds more than one object that fits the description, then Quick Test ignores the learned
description, and uses the smart identification mechanism to try to identify the object.
• A Smart Identification definition can help QuickTest identify an object, if it is present, even F
~
when the recorded description fails due to changes in one or more property values
rr- -
Object Identification Dialog Box f
Identification
I
f
'-.~­
q

'
-c----
li
[i

18 Mr.Venkat (Sr. Test Manager) Page 17 ofll8


~llvelech
fivtfy W/iofl ..fiiiWos

Types of Objects
There are two types of object
Test Object:
}- Objects in Object Repository are Test Objects.
}- Test Objects are helps to QTP to identify and check the object during the run session.
Run-Time Objects:
}- Objects which are in Script are Run-Time Objects.
}- It is the actual object in your web site or application on which methods are performed
during the run session.

Object Repository
}- Interface between QTP Script and the application
:: }- Contains Logical Name and physical description of the objects
}- The Object Repository window displays a tree of all objects in the current action.

Navigation:

Name:
Class: Dialog
i···(iii;i Agent Name:

:''
:· mm Pa~·sword: Repository: 1.-L-oca-.-,---------,_...;..;......._--.,_

fr est objeci detaas

Comment

There are two types of Object Repositories:

1. Per action object repository:


Stores objects that are associated with one specific component [Action], so that only that
component can access the stored objects. t--
r:

2. Shared object repository:


Stores objects that can be accessed by multiple components.

Mr.Venkat (Sr. Test Manager) Page 18 of 118


Object Repository Manager

~ The Object Repository Manager enables you to open multiple shared object repositories and
modify them as needed. You can open shared object repositories both from the file system.
Navigation: ·, ·· .. ~

Go to Resources Menu -7 Object Repository Manager 1-

Nome
~~)i;j~j;\'~~"'@)-~j~~f:t~~i
nt~tivecloss : SysListView32
~,t~1~jj!~ti¥:~ ·,:~~·'.;~\Jit-~,G~tJ;~~41g;:~J;~~1t{t%~.
Type.Vl!lue ;None
;:lM~~)~~~s ', ./~;,:J:(:~~b; ~;:~~;~:' :J,h:;;:')l~%-~i$:1~1
Enoble Smorlldentificot...:~-- -.·. ·
Comment

Operations performed by Object Repositorv Manager


1. Creating New Object Repositories
2. Opening Object Repositories
3. Saving Object Repositories
4. Closing Object Repositories
5. Manipulating Objects in Shared Object Repositories
6. Managing Repository Parameters :~
,-~-
,_;
7. Modifying Test Object Details
8. Locating Objects
9. Performing Merge Operations
10. Perfonning Import and Export Operations
Object Repository Comparison Tool
Navigation:Go to Resources Menu-70bject Repository Manager-70RM- Tools
Menu-70bjectRepository Comparison Tool

Object Repository Merge Tool


Navigation:
f--
Go to Resources Menu-7 Object Repository Manager-70RM- Tools Menu-70bject
Repository Merge Too!

Mr.Venkat (Sr. Test Manager) Page 19 of118


~
,~--
\

Merge and associate Repositories

Navigation:
1. Generate Script for Project Login and Observe objects are stored in Object Repository.
2. Export and save the objects (ORl) of scriptl, using Object Repository (Go to Resources
menu and click Object repository. In Object repository go to File menu and click on 'Expor1
Local objects' and Save it into existing folder) and Save script 1.
3. Generate Script for Project Home Page and observe Objects are stored in Object Repository
4. Export and save the objects (OR2) of script2, using Object Repository and save Script2.
5. Go to QTP -7 Resources menu -7 Select Object repository manager
6. In ORM go to Tools menu click on Object repository Merge tool and Select Primary file as
OR 1 and Secondary File as OR2 and click on [Ok]
7. Save file as OR3
8. Associate OR3 into "Script 1 and Script2", while navigating to QTP Resources Menu and
click on associate repositories and add Repositories OR3 to Actionl and click on (Ok]
9. Run the scripts and observe results (Both scripts are used single repository-OR3)

(Or)
Second Best Method:
l. Object Repository creation for Project - while navigating to Object Repository and Add
~
Objects to Local
2. Export these repository into Local folder (Project\Object Repository)
i

3. Write manual scripts for Current project f;

4. Associate Repository to all Scripts, while navigating to Resources Menu and click on
associate repositories and add Repository
5. Run the scripts and observe results (All scripts are used single repository)

Mr.Venkat (Sr. Test Manager) Page 20 of 118


~liveTech fil·efy ttstinn sol»tioDJ

Object Spy
1. It is used to view object properties and Operations.
2. Displays
);> Object hierarchy tree
);> Properties
• Native Properties (Run Time properties)
• Identification Properties (Test object Properties)
Operations
);>
• Native Operations (Run Time Operations)
• Test object Operations
Navigation: Tools -7 Ob'ect I
I
test objec1
hierarchy tree t~ ···.·

ol>jecl type fil1er


object details tab

object proper1ies

selected prop.arty,
or operation

lOrt

QTP Script Generation and Execution Process


CD
as

Page 21 of118
18 Mr.Venkat (Sr. Test Manager)
~--~

~
;
1. Start Recording }
2. Learn Object (Storing object in Object Repository) During Recording
3. Script Generation

4. Catch Entry in Object Repository


(Object Properties in Object Repository)
(match the properties in AUT)
5. Identify Object in AUT } During RUN

AUT: Application Under Test

How to add objects in Object Repository


Navigation:
1. Resources~ Open. Object Repository~ Click on Add Object Icon~ Show Object with
Hand Icon ~ Click on [Ok]
2. Select Option [Select Object Only, Default Object Types, All Object Types, Selected Object
Types] . .
3. Click ori [OK]
i 4. Export these repository to Local Framework Folder

I
I
I
What is the extension ofthe Shared Repository?
.tsr (Test Shared Repository)

- - Ii How to associate Shared Repository


There are three ways to add shared repository
1. Using Associate Repository
2. During Runtime
3. Using Action Properties

1. Using Associate Repository


" Go to Resources Menu ~ Associate Repository ~ Click on Add ·_~:_
11
r-;

" Select I Location of Repository file path~ Click Open


• Associate with Action~ Click on [Ok].

2'. During Runtime


repositoriescolJection.Add "Repository file path"
Ex: repositoriescollection.Add "F:\loginrep. tsr"

3. Using Action Properties


Right click on Expert View ~ Go to Action ~ Action Properties ~
• Select "Associated Repositories" tab ~Click on Add~ Select I Location of Repository
file path r-
• Click Open~ Click on [Ok] )
Note:
ln QTP every action will have one local repository; apart from that local repository one can
associate more than one shared repository to the action.

Mr. Venkat (Sr. Test Manager) Page 22 of 118


Drawbacks of Object Repository:
~ It takes lot of time for identifying the object, when the object is changing dynamically during Run
time.
~ If the object Repository size increase then the execution speed will be decrease.
);;> To prepare script using object repository build is required I
.,,_
Descriptive Programming
I
Definition i
~ If we specify description of the object in the program it self that can be called as Descriptive I
Programming.
~ Using Descriptive Programming we can execute test script without objects in Object Repository.
I
~ We can execute the test script without Object Repository.
Advantages:
1
~ Fast execution.
~ Easy to identify the objects.
Jject ~ We can prepare Script without having build.
Disadvantages: ·""
~ It takes lot of time to design test Script -Time consuming for test script design

To design Descriptive Programming, there are two ways:


1. Specifying the properties and its values directly in the statement (script)
2. Description Object

1. Specifving the properties and its values directly in the statement (script)
Syntax I Code:
Browser ("PJ :=Value", "P2:=Value", .... ). Poge ("P1:=Value", "P2:=Value", .... ).Object.
("P1 :=Value". "P2:=Value", .... ).Operation I Method.

Example 1:
Prepare descriptive Programming for "Logir;t" Operation in Flight
Reservation
• SystemUtil.Run "C:\Program Files\HP\QuickTest
Professiona1\samp1es\flight\app\tlight4a.exe"
• . Di<llog("text:=Login").\VinEdit("attached text:=Agent Name:").Set "Venkat"
• Dialog("text:=Login").\VinEdit("attached text:=Password:").Set "mercury"
• Dialog("text:=Login").WinButton("text:=OK").Click
:11 Window("text:=Flight Reservation").Close
Example 2:
Prepare descriptive Programming for "admin login" Operation of project.
,-,-
ory

~an

118 Page 23 of 118 =


~~-

r . nn

f
Example 3:
'Prepare Descriptive Programming for Google Search

Bravser ('' ~cu-o< : " I{ CkJ,Jie ':J Ft:5e L"btl~ : ~ 1';, DdsJe :) 0eb ~·1:: (" ~c o/j o :>c

qCfJie 'j. P{J<:(" i'il:te : o 4oo:rJe ~~. ~ /,q lb, ( "~ . _


ll L'Cte l'eL~-J,
BrwJ.sec('' ))c..,e; "

' - Cf ~le ~c•Yt.I:J


Cli'cJ:__

2. Description Object
To create Description Object we can follow below syntax.
Syntax I Code:
Set Object Name== Description.Create
Object Name ("Property Name"). Value= "Property Value"
Example 1:
Using description object, prepare descriptive Programming for "Login" Operation in
Flight Reservation
• Set dia = description.Create
• dia("text").value=="Login"
• Set Ana = description.Create
• Ana("attached text").value="Agent Name:"
• Set pwd = description.Create
·~ pwd("attached text").value="Password:"
• Set but= description.Create
• but("text'').value="OK"
• Set WC==Description.Create
• WC("text").value=="Flight Reservation"

• S ystemutil.Run "Path of Exe"


• dialog( dia).winEdit(Ana).Set "mercury"
• dialog(dia).winEdit(pwd).Set "mercury"
• dialog( dia).winbutton(but).Click
• Window(WC).Close

Mr.Venkat (Sr. Test Manager)


Page 24 of 118
~liveTech
. FU.f; tmi•n "'""""

Example 2: Using description object, prepare descriptive Programming for "admin Login"
Operation of current project.
S 9!- bfO .:::= CX2.SC"I;ph{ly) . cr-fbJe. SjS~f.·r 0.tn '1 le~pkv~/ uhttp :jj.j~
s.V:. r~ :: 0e3Cn'p-h'~ . c~ go~; f"4>p(()C3 "a/'; ,.
sci Or)Q ::: D<ZSGrlpJ-ic() • C'rWk 8 r045& O:o·v. P'tfe Ci'~ J. !-£.bc-ot·t-(_ uh V-
sci- pwd. -= fy2,5Cn-plit?J. ~reJe.
sel:: ~t- -= cesc npHcJ?· ue::Je
se± b--rot = oe.scr~'pl,(n. ctt'bte_
tl p /'Y) (_ L/
:sel- bm·Ac:K ( ( lr) c.JY) e_ (/
pmc r., C..· iJ

BrL-W~L breD· p~ e LPGjJ· Nebhll#-cr] (_ ~t)­


.) ll
I])J
r~. Ad_d ll.b_d:·lt III upffX I0C.·u
Lild:...
UVJQ. . Ad:L ll 'h::vr'x: I j li(LS~d. If

~?_/,. pwd_. AJ_d_ L\ 71::Lv}£ t; \..\ fCJ..S56.X!rJ It


but, 1\d.d \\ Y)(;.me '/1 \( S CJh txJt- It
brol· ttdd l \ Y)GVnt' If
/
t\Ne_w ~ ' I(

Example 3:Prepare Descriptive Programming for Google Search Using Description Object

Run Modes
Two Run modes i;
1. Nonnal- We can set timeout "
I'

2. Fast
Tools -> 0 ions -> Run

:-::• Genf!u.,l
. · T eMt A ecognilion
Run
Folder$
Active S croen Run modo··· ······································ ·· ·· · ··················~····· · ··· ········-···-···-····-··-···--····---··---··-··--·--···········-····----·, .-,-
·li!IID
.c'

·-
:. Screen Capl....,re
Windo.....,s Applrc~••crns
r-. Normal {displ.eys e1-<ecution marker)
Oelcy eoch step el<ecution by: ~ miKiseconds
1-
: Adv.enced r Fest
·:-; ~eb ············-·······················-·-·····-······· ....
P.,g~/Ftcrn.,. Options
Advonced

1 : Allow other HP products to run tests and components


Stop comm.!'lnd .shortcvt keo,>' Jctrl .. Alt + F5

Mr.Venkat (Sr. Test Manager) Page 25 of 11 8 w - --


i
~- ·-·
1
. -
.*liveTech !it-tlj Jtsling so{JJIJ~)D$

Synchronization
>- When you run tests, your application may not always respond with the same speed.
For example, it might take a few seconds: '
• For a progress bar to reach I 00%.
• For a status message to appear.
• For a button to become enabled.
• For a window or POP UP message to open.
> You can handle these anticipated timing problems by synchronizing your test to ensure thn
QuickTest waits until your application is ready before performing a certain step.
I
Options to synchronize the tests
>- To give waiting time QTP there are three ways such as
' ''
I. Synchronization Point
2. Wait and Exist
3. Increase timeout
1. Synchronization Point
> Instructs Quick Test to stop the test until the object property achieves the value you specify
(or until a specified timeout is exceeded).
> We can use this option to give waiting time to the tool based on specific object property
value.
Syntax:
Window("Window Name").Object("Object Name").WaitProperty "Property Name'', "Property
Value", Timeout in Milliseconds.
Web Application
> Browser ("Home Page").Page ("Home Page").WebButton("Submit"). WaitPrope11y
"visible", true, I 0000
Navigation:
1. Place the cursor in your required place of test script
2. Click on Start recording
3. Go to Insert Menu and click on Synchronization Point
4. Show object with Hand Icon and Click [Ok]
5. Select property Name (Enable) and Enter Property Value (True)
6. Set timeout in Milliseconds, Click [Ok] and Stop Recording.
Note:
1 Second= 1000 Milliseconds
~ While recording select Insert> Synchronization Point
S~lecting the object Adding Synchronization Point

-~-
I~

Mr.Venkat (Sr. Test Manager) Page 26 of 11 8


2. Adding Exist and wait Statements
);;>You can insert "Exist or Wait" statements that instruct QuickTest to wait until an object
exists or to wait a specified amount of time before continuing the test.
);;> You can use Exist and/or Wait statements in the expert view. ,
);;> Exist statement return a Boolean value indicating whether or not an object currently exists.
Example:
Browser("Home Page").Dialog("Message from Webpage").Exist
);;> Wait Statements instruct Quick Test to wait a specified amount of time before proceeding to
that the next.
Example:
Wait(lO)
3. Increase timeout
);;> The amount of time QuickTest waits for objects to appear or for a browser to navigate to a
specified page is insufficient, we can increase the default amount of time that QuickTest
waits for a Web page to load.
> QTP maintain "20" Seconds as default object synchronization Time out.
);;> Default time out is not sufficient, then we will increase Timeout in settings.
y
Navigation:
File Menu-> Settings-> Run Tab-> Change Object Synchronization time out-> Click on [Ok].
Transactions
Start Transaction & End Transaction
:ny It is used to calculate the time taken to execute a block of statements or to estimate the speed of
processing.
Syntax:
Services.StartTransaction <"Transaction Name">

Statements

Services.EndTransaction <"Transaction Name">


Inserting Transactions :,;

Choose Insert > Start transaction t-


[!

Ending Transactions
Choose Insert > End Transaction
i: , -
-
-,_-

~----­
t

K --------

Page 27 of 118 ,
Mr.Venkat (Sr. Test Manager) --'-
1
-
~ - - ..
~LiveTech
E
N'tfJ IUiilrJI schtiau
L
VB Script
Purpose
» When the tools provided by QTP are not sufficient to test an application, VBScript coding can b':
used.
~ VBScript was created as a web programming language by Microsoft and licensed by many companic;i
for use in their tools.
I. Checkpoints -Check
2. Synchronization points -Wait
3. Output values - Retrieve information
4. Parameterization - Data configuration
5. VBScript -Adds programmable logic (For verifying Expected Result)
• Last option
• Very powerful
What is VBScript?
~ It is a scripting language
~ It is a lightweight programming language
~ It is a light version of Microsoft's programming language Visual Basic

Diff b/w Programming and Scripting:

Programming Scripting
I) Develop something from Scratch I) Used to combine existing Components
~) SelfExecutable 2) Requires a Host
3) Compiled or Interpreted 3) Interpreted
!4) Complex !4) Easy
VBScript Data Types
~ VBScript has only one data type called a Variant.
~ A Variant is a special kind of data type that can contain different kinds of information, depending on
, how it is used.
~ Sub-Types supported by Variant
1. Empty 6. Currency
2. Null 7. Long
3. Boolean 8. Double
4. Byte 9. Date (Time)
5. Integer 10. String·

Variable Nami"ng Restrictions


~ A Variable is "Container" for information you want to store.
'~
>- A variable's value can change during the script.
~ In VB Script, all variables are of type variant, which can store different types of data.
Rules for Variable Name:
> Must begin with an alphabetic character (Letter).
> Cannot contain a period(.).
~ Cannot exceed 255 characters.
> Must be unique in the scope in which it is declared.

Mr.Venkat (Sr. Test Manager) Pnge 28 of 118


~liveTech firefy ltshnflSll{llti<'US

Declaring Variables
);> Variables can be declared by using Dim (or) Public (or) Private Statements.
);> Dim Statement - available to all procedures within the script.
:an be );> Public Statement -available to all procedures in all scripts.
);> Private Statement - available only to the script in which they are declared.
'anies
Declaring Variables- Example
);> The dim declared before all functions, becomes a "global variable"
);> The dim declared within a function, acts as a "private variable"
Ex: dim a, b -7 a, b are variables scope with in the script/function.
function
dim k -7 k is Private
end function

Scope and Lifetime of Variables


Procedure Level Scope:
When you declared a variable within a procedure, the variable can only be accessed within that
procedure. When the procedure exits, the variable scope is destroyed. These variables are called Local
variables. You can have local variables with in the same name in different procedures, because each is
recognized only by the procedure in which it is declared.

Script Level Scope:


If you declare a variable outside a procedure, all the procedures on you script can access it .The Life
time of these variable starts when they declared, and ends when the script is closed.

Best Practice for variables:


Option Explicit :
I
If we write Option Explicit, we must declare all variables (Force explicit variable declaration).
> Eliminate unnecessary creation of variables at runtime.
: ;. . It avoids variable typo mistakes.
r
e_ ______ _

m
> To avoid confusion in code where the scope of the variable is not clear. -1

on Should be the first statement of the script.


I
r.
ex: Option explicit
Dim name
I
i1
,-,-
::
name= "John"

VBSc'ript Constants
: ;. . Constants in VBScript can be created using the Const statement.
> Declares constants for use in place of literal values.
Example
Canst MyString = "This is my string."
Canst MyAge = 49 ,_,1_

.--
Array Variables "
> Assign More than one value to a single variable. Can create a variable that can contain a series of
values called an array variable.

Declaration of Array variable uses Parentheses ()following the variable name.

Types of Array:
~:-

8
Mr.Venkat (Sr. Test Manager) Page 29 of 118 r
f ·---
1. Static Array: Size can be specified at the time of declaration
Ex: Dim Name(2)
II Number in parentheses is 2. Array contains the 3 elements start at ZERO.
Name(O) = "john"
Name(l) = "mery"
Name(2) = "moren"
II Retrieving value of array using the Index of the array
Dim arrayvalue
arrayvalue = Name(O)

2. Dynamic Array : Array size can be changed


Ex: Dim a()

Array starts with the index '0'


Ex : a[O] to a[5] for Array a(S)

The ReDim statement is used to size or resize a dynamic array that has already been formally
declared.
Redim a(lO)

VBScript Operators - Arithmetic Operators

Description Symbol
Addition +
Subtraction
'
:i String concatenation &
Multiplication *
Division I
Exponentiation 1\

Comparison Operators
Description Symbol
Equality =
Inequality <>
Less than <
Greater than >
Less than or equal to <=
Greater than or equal to >=

Logical Operators
Description Symbol
Logical negation · Not
Logical conjunction And
Logical disjunction Or

VBScript Input
InputBoxO:
It displays a dialog box containing a label, text box for entering data, (OK] and [Cancel]
Ex: a= lnputBox ("Enter the value")

Mr.Venkat (Sr. Test Manager) Page 30 of 118


r
!
~liveTech
m'tfy ltsli•fl wt.ti...

VBScript Output
MsgBoxO: It displays a dialog box containing a message and buttons.
Ex: MsgBox ("This is the value")
dim name
name= "John"
box" value of the variable name:" &name
[Jiiiii!!!ii!--

Conditional Statements
1. If Statement
~ If...Then ... Else statement
~ If...Then ... Eise If statement
~ Nested If statement
2. For...Next
~ For To ... Next
~ For each ... Next
3. While
~ While ... Wend
~ Do - Loop ... While
~ Do- Loop ... Until
4. Select Case statement

1. If Statement
You should use the if ... then .. Else .. Statement if you want to
~ Execute some code if a condition is true
~ Select one of two blocks of code to execute
Ex:
l.l If... Then ... Else statement
IF Condition THEN
statements
ELSE
statements
-:~-
END IF :·J=-:-
·~- - -

Ex:
i = InputBox ("Enter the value")
ifi < 10 then
MsgBox ("Good morning!")
else
MsgBox ("Have a nice day!")
end if

Mr.Venkat (Sr. Test Manager) Page 31 of 118


1.21f... Then ... Eise If statement

IF Condition] THEN

statements

ELSEIF Condition2 THEN

statements

ELSE

statements

ENDIF

ENDIF
1.3 Nested If statement
IF Condition! THEN
IF Condition2 THEN
statements
else
.. ' statements
ENDIF
ENDIF
Ex:
i = InputBox("Enter the value")
ifi < 20 then
ifi < 10 then
MsgBox("Good morning!")
else
MsgBox ("Have a nice day!")
end if
end if

2. For ...Next
» Uses a counter to run statements a specified number of times.
» Repeats a group of statements a specified number of times.
2.1 For To ... Next
For counter= start To end [Step step}
· [statements]
Next
Ex 1: __u,_ _
,
Tota/=0
For i=O to 5 step 1
Total =total+]
r-
iJ

Next ";
-~-

2.2 For each...Next


For each counter in variable
[statements]
Next

Mr.Venkat (Sr. Test Manager) I


~
Page 32 of 118
Ex:
dim names(2)
names(O) ="Testing"
names(l) ="Java"
names(2) = "J2EE"
for each i in names
MsgBox(i)
next
3.Wbile
);> Loops while a condition is True.
);> Executes a series of statements as long as a given condition is True.
3.1. Wbile ... Wend
While condition
[statements]
Wend
Ex:
i=l
While i < 5
MsgBox(i)
i=i+ 1
Wend

3.2 Do - Loop ... While


);;> Loops while or until a condition is True.
);;> Repeats a block of statements while a condition is True or until a Condition becomes True.

Syntax:
Do
statement
Loop While condition

Ex:
i=l
Do
MsgBox(i)
i=i+l
Loop While i < 5

3.3 Do- Loop ... Until


Do
statement
Loop Until condition
Ex:
i=l
Do
MsgBox(i)
i=i+l
Loop Until i = 5

.--
Page 33 of 118
8 Mr.Venkat (Sr. Test Manager)
4. Select Case statement

SELECT CASE variable


CASE "Value I"
statements I
CASE "Value2"
statements2
CASE Else
statements3
END SELECT
Ex:
I:
i == InputBox("Enter the value")
Select case i
case "A"
MsgBox("A ")
case "B"
MsgBox("B ")
case else
MsgBox("No")
End select

!:

-''-

Mr.Venk:at (Sr. Test Manager)


[___
. :;,_
Page 34 of 118 t_ _
~
E

!
.* liveTech fiNfyltstinO"'{Juim

VB Script Built-in Functions


II
(1) Left II
i
We can use this function to get a specified number of characters from the left side of a string.

c
Syntax: left (String, number)

~
Ex: x="sairam"
msgbox left(x,3) . .

2. Right
We can use this function to get a specified number of characters from the right side of a string. I
·\r

Syntax: right (String, number)


Ex: x="sairam"
msgbox right(x,3) IC_,;~.... JI"·

3.Len
We can use this function to find length of a string
Syntax: len (String)
Ex: x="sairam" msgbox len(x)

4.Mid
We can use this function to get a specified number of characters from the given string.
Syntax: mid (String, Start Position, length)

Ex: x="$1245" msgbox mid(x,2,len(x)-1) •r:J_-j_·


' -----·
Ex: x="Rs.14258/-" msgbox mid(x,4,len(x)-5)

5. LTrim
We can use this function to remove spaces from the left side of a string.

Syntax: ltrim (String)

Ex: x=" Sai"


msgbox ltrim(x)

6. RTrim
We can use this :function to remove spaces from the right side of a string.
Syntax: rtrim (String)
Ex: x="Sai "
msgbox rtrim(x)

7. Trim
We can use this function to remove spaces from both the sides of a string.
Syntax: trim (String)
Ex: x=" Sai "
msgbox trim(x)

Page 35 of 118
18 Mr.Venkat (Sr. Test Manager)
~tlveTech
lit•fy Us~Ult! scfuh'ons

.
···~··.·.·•.
8. UCase .

'.. . .
We can use this function to convert Lower Case into Upper Case .•·
··..•...
:
5AlR""' · ·· .·.··. .
.. ·•·.............. ..·· •.
.
...

Syntax: ucase (String) 't lc·&"""·:·j •


Ex: x="sairam" msgbox ucase(x) . 'HC'"':'tttf:k ._"

9. LCase
We can use this function to convert Upper Case into Lower Case
Syntax: lease (String)
Ex: x="SAIRAM"
msgbox lcase(x)
10. Strreverse
We can use this function to reverse the string.
Syntax: strreverse (String)
Ex: x="SAIRAM"
:I
msgbox strreverse(x)

11. Strcomp
We can use this function to compare two strings
Syntax: strcomp (String}, String2, Compare)

0
Binary Comparison
Ex:
x=''SAIRAM''
Y="sairam" lr··--·oic""·-~t
r~·r-·---· . . . --
·. i If strcomp(x,y,O)=O then
•. !
msgbox "Both are Equal"
else
msgbox "Both are not Equal"
end if
12. Cint
We can use this function to convert given value into Integer.
Syntax: cint (expression)
Ex: x="l0.54"
msgbox cint(x)
13. Cdbl
We can use thi:o function to con-vert the given value into doubie.
Syntax: cdbl (expression)
Cstr ·~·
~
We can use this function to convert given value into String. F

Syntax: cstr (expression)


14. Round
We can use this function to rounding the value.
Syntax: round (expression, No. of decimal places)
Ex: x="10.123456789"
msgbox round(x,3)
;-
[
Mr.Venkat (Sr. Test Manager) Page 36 of 118 ~
F-

!
15. Split
It is used to return "0" Zero Based one dimensional array containing a specified no. of substrings.
Syntax: Split (expression, delimiter)
Ex: s="lndia is a great country"
arr=split(s, " ")
msgbox arr(O) = India
msgbox arr(l) = is
msgbox arr(2) = a
msgbox arr(3) great
Msgbox arr(4) = country
16. Join
It is used to return a string created by joining a specified no. of substrings contained in an array.
Syntax: join (list, delimiter)
Ex: s="India is a great country"
arr=split(s, " ")
msgbox arr(O) India
msgbox arr(l) = lS

msgbox arr(2) a

msgbox arr(3) great


msgbox arr(4) = country
msgboxjoin(arr," ")
Note
How to add two variables values.
a="Sai"
b="Ram"
msgbox a&space(lO)&b

17. Space
It is used to create a specific No of spaces
Syntax: space (Number)
18.Rem
It is used to insert comment.
Syntax: rem statement
19. Date 11}9}2008

It is used to return current system date.


Syntax: msgbox date
20. Time
It is used to return cirrrent system time.
Syntax: msgbox time ,.-;-

! tf9tzooa tt:1t:~ AM

21. Now
Syntax: msgbox now

~~tax::~~~·~:=~yname(weekday( date)) •· '! ~~=~


Page 37 of 118
18 Mr.Venkat (Sr. Test Manager)
Procedures
VB Script has two kinds of procedures
1. Functions (Function Procedure)
2. Procedure (Sub Procedure)

1. Function Procedures:
Perform action & Returns the outputNalue
Syntax:
Function function name()
statements
function name = a+b
End function
Function returns the value with function name.
2. Sub Procedures:
Perform action & doesn't return the output/Value
Syntax:
public sub procedure_name( arguments)
statemets
End sub
User defined Functions
> To create User Defined Functions we can follow below syntax.
> Like as programming language 'VB Script' is also allows you to create 'User Defined Functions' for
repeatable operations.
Method 1:
Public I Private Function Function_Name (Arguments)

Statements

End Function
Method 2:
I. Go to Insert menu and click on "Function Definition Generator"
2. Enter name and add parameters and click on [Ok]
Ex:
Public function addition (x,y)
z=x+y
addition= z
End Function
Function LRbra:ry

> Function library is collection of Functions and Sub Procedures. II _r:_


>
I
.-~:
Removing the redundancy and Duplication on our Test pack.
> Whenever we required to use of this function library, we need to associate this Function library to the.
QTP. So that we can make a call to all the functions wailable in that Function library.
How to create Library File
Navigation
:;.. . Create required function for the required repeatable operations. f
;; Select the script --7 Copy the Script --7 Paste the script in Notepad --7 Save the file with ".vbs" i
extension i

Mr.Venkat (Sr. Test Manager) Page 38 of 118


~liveTech fi<•tfyiiSiillflu>Wti.. s

How to associate library file to Test before execution


Navigation:
1. File Menu -7 Settings ~ Resources Tab ~ Add Associated function library -7 Browse file path -7
Click Ok.
(Or)
2. How to associate library file during Runtime
Syntax: execute file "Path of file"
Example 1:
Public Function addition (x,y)
z=x+y
addition == z
End Function
Save as .vbs file in Notepad and Associate this to Function library.
'*********************************************************************************
'Calling the above function in Script
a=lO
b=20
c=addition (a,b)
msgbox c

Example 2:
Public Function Login (Usemame, Password)

IS' for Systemutil.run "Path of application"


Dialog("Login").WinEdit("Agent Name:").Set Usemame
Dialog("Login").WinEdit( "Password:"). Set Password
Dialog("Login").WinButton("OK").Click

Ifwindow("Flight Reservation").Exist Then


Login=="Test is Pass"
else
Login=="Test is Fail"
End If

End Function

Save ~;ts .vbs file in Notepad and Associate this to Function library.
'*********************************************************************************
'Calling the above function in Script
11 · Result==Login("Venkat","mercury")
• msgbox Result
r;
o-.-

to the!~
~
!
![

!
'
I
I

Page39of118
~ 118
Mr.Venkat (Sr. Test Manager)
~liveTech
lktfyltslillfiS<16tti<»J•

QTPMethods

In QTP mainly we used below methods to automate web application


1. GetVisibleText
2. GetROProperty
3. GetTOProperty
4. GetltemsCoW1t
5. Getltem
6. GetContent

1. GetVisibleText
We can use this method to capture visible text.
Code:
Variable=Window("Window Name").Obj ect("Object Name").GetVisibleText()
2. GetROProperty
>- We can use this method to capture run time property value into variables.
>- We can use this methud to. capture object property "from the application"
Code:
Variable= Browser("Browser Name").Page("Page Name").Object("Object Name").GetROProperty
("Property Name")
3. GetTOProperty
>- We can use this method to capture text object value into variable. Or
>- We can use this method to capture object property value from the object Repository.
Code
Variable = Browser(''Browser Name").Page("Page Name"). Object("Object Name"). GetTOProperty
("Property Name")
Difference between GctVisibleText and GetROProperty:
"' GetVisibletext enables to capture the static text displayed in the specified area.
~ GetROproperty will retrieve the dynamically changing text during run-time.
4. GetitemsCount
We can use this method to count number of items in the Combo box/List Box.

5. Getltem
We can use this method to get a specified item from the Combo Box

6. GetContent !
We can use this method to get content of the Combo Box. i
f
r
I;

1. Report Event
QTP Test Results

We can use this method to report an event to the Test Result Window.
II
Syntax:
Reporter.ReportEvent EventStatus, ReportStepName, Details
micPass (0)
micFail (I)
. D one\"-
m1c ,...,)
micWaming (3)
Reporter.Repor1Event micPass, "What we are verifying", "Expected"

Mr.Venkat (Sr. Test Manager) Page 40 of 1i8


.*liveTech lirtfy WMfl ..,(,ti,»a

It just reports only the contents which is given in double quotes.


Note: mic ->micro
rnicPass -> microPass
rnicFail -> microFail - ..... ?.

2. Print
• It is used to display your specified message in Quick Test Print log.
Syntax: Print "Message"
3. Msgbox
• It is used to display specified message in Dialog box
Syntax: msgbox (''Enter the value")
Ex:
a=lO
b=20
If b=a+ 10 Then
msgbox "b is equal to a"
print "b is equal to a"
reporter.ReportEvent micPass, "b is equal to a", "Test is Pass"
else
msgbox ''b is not eqaul to a"
print "b is not equal to a"
reporter.ReportEvent micFail, "b is not equal to a", "Test is fail"
End If

• Execute .exe files from QTP:


Syntax:
Systemutil.Run "-----"'--"Path of exe or To Run URL--------"
or
lnvokeapplication "--------exe Only-------"
• Exit Run:
If Exit Run is used, "The control come out from the particular Statement".
• Use of QTP Script
For Navigating.
• Use of VB Script:
Verifying Expected Result.

-~:-

I
I
I

I'
i
I
i
18
I Mr.Venkat (Sr. Test Manager)
Example for QTP methods and Report Events

Test Scenario 1:
1. Activate Window
2. Enter User Name and Password and Click on [OK]
3. If [Next] is enabled, User is authorized. If next is disabled, User is unauthorized.

!J.se~ Name:

Password:

., " ·" ~-~'OTmi>J . •·•.· Next· ..· l


? •.. ·•
! Cancel j

ophun toX-fL'c.'t.

0 ;/Y) shr053

D•tJL:_j ( ''Lc~"''') · Adiva.i--e_

D•'oJ~Jc ''Log10i). /:J;YJ-e_M c\ UtSe.·r fVC.-1/VJe ':J ·sct ll~r ,,

D· cJ.2j cL lI 0 <0 'j . LJ; ~~ ecbt


V) (I I Po.ccS W<-rF') sel
I LI

Sh~ n:,~ (Lea'"'} C "11!£>.1- "). GeH!.opnp"j L''e"cble~


\'

= IJ;"hHOJ
If sh "'OJ ::: \I 1 v L1. e IJ -f{\0..4

[ ~~ e d / u.s ev •S au Kon.-<.c-1:
"'' res+ (s p~ 11
,_
.. _

l·.
[

t-

r------

Mr. Venkat (Sr. Test Manager) Page 42 of 118 .,


L-
_,_
~

t
'E

QTP Script
Test Scenario 2:
Book a flight ticket and Verify the booking stored
1. Open the Login window
2. Verify the Login window existence
3. Enter Agent Name, Password and click on [OK]
4. Verify the existence of "Flight Reservation window"
5. Enter the date in "Date of flight" field
6. Select one place from "Fly from"
7. Select one place from "Fly To"
8. Click on [Flights]
9. Verify the existence of"Fiight Table"
10. Select one flight from the "Flights List" and click on [Ok]
11. Enter the Customer Name, No. of Tickets and Select class
12. Click on [Insert Order]
13. Verify "Insert Done" message
14. Open "Open Order ... " Dialog
15. Select the checkbox "Openorder"
16. Enter the OrderNo and Click on [OK]
17. Verify the Ordemo displayed in Flight Reservation
18. Close the application

Real Time Test Script:


' Project Code : L T 333
'Project Name : SpiceJet
' Created By : Venkat
'Date Created : 19-Nov-2012
'Test case Name : Indian Airlines
'Test case Objective: Book a Flight Ticket & Verifying the booking Storage
' Expected Result : Flight ticket must be booked

'************************Variable Declaration***********************************
Option Explicit
Dim strtempContent, OrdNo,OrdNo 1
'***********************Functional Scenario*************************************
' Open the Login \Vindow
System util.Run ".C:\Pro gram FiIesIHP\QuickTest Professional\sampleslfl igh t\appIflight4a. exe"
' Verify login window existence ii - , -
,

If dialog("Login").Exist Then
Reporter.ReportEvent micPass ,"Verifying the Login Dialog","Login Dialog is

displayed"
else
Reporter.ReponEvent micFail ,"Verifying the Login Dialog","Login Dialog is Not

displayed"
'2nd If

18
Page 43 of 118 .•
;----
~
-

Mr.Venkat (Sr. Test Manager) ~


I !
rr·
'
,
-*liveTech
'

'l•.

i: firtfjttstinnsoftttic,ru
l
1
·1 l:
·,
' Enter Agent Name and Password
dialog("Login").WinEdit("Agent Name:").Set "mercury"
dialog("Login").WinEdit("Password:").Set "mercury"
' Click on [OK]
dialog("Login").WinButton("OK").Click
1
Verifying Flight Reservation Window
If window("Flight Reservation").Exist Then
Reporter.ReportEvent micPass ,"Verifying the Flight Reservation window", "Flight
Reservation window is Opened"
else
Reporter.ReportEvent micFail ,"Verifying the Flight Reservation window" ,"Flight
Reservation window is Not Opened"
'I
End If
'Enter the date in "Date ofFlight" field
window("Flight Reservation").ActiveX("MaskEdBox").Type "111111"
'Select Place From "Fly From" Combobox
wipdow("Flight Reservation").WinComboBox("Fly From:").Select "Paris"
1
Select Place From "Fly To" Combobox
window("Flight Reservation").WinComboBox("Fly To:").Select "London"
1
Click on Flights Button
window("Flight Reservation").WinButton("FLIGHT").Click
' Verify flights table window
1f window("Flight Reservation").Dialog("Flights Table").Exist Then
Reporter.RepcrtEvent micPass ,"Verifying the Flight Table Dialog","Flight Table' Dialog is
displayed"
Else
Repor1er.ReportEvent micFail ,"Verifying the Flight Table Dialog","Flight Table Dialog is
Not displayed"
End If
' Selecting the flight from the List
windO\v(''Flight Reservation").Dialog("Flights Table").WinList("From").Select(3)
' .Click on [OK]
\vindow("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
I Enter the Customer Name
window("Fli~ht Reservation").WinEdit("Name:").S·d "LiveTech"
1
Enter the No of Tickets
window("Flight Reservation").WinEdit("Tickets:").Set "2" ~
~
' Se)ect a Class
~
window("Flight Reservation").WinRadioButton("Economy").Set
' Click on [Insert Order]
window("Flight Reservation").WinButton("Insert Order").Click
' \Vait tiJJ "Insert Done" message display in control

. ---

~ ..

r-
;·-· --
Mr.Venkat (Sr. Test Manager) Page 44 of 118
I
*liveTech linfy wlinn ..r.h~m

Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty "text", "Insert


Done ... ", 30000
'Verify "Insert Done" message
strtempContent=window("Flight Reservation").ActiveX("Threed Panel
Control").GetROProperty("text")
If strtempContent="Insert Done ... " Then
Reporter.ReportEvent micPass ,"Verifying the Insert Done message ","Insert Done message
is displayed"
else
Reporter.ReportEvent micFail ,"Verifying the Insert Done message ","Insert Done message
is Not displayed"
End If
OrdNo= window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")

' Open the OpenOrder Window


window("Flight Reservation").WinMenu("Menu").Select("File;Open Order... ")
' Select the checkbox "Openorder"
window("Flight Reservation").Dialog("Open Order"). WinCheckBox("Order No. "fS~l "ON"
'Enter the OrderNo
window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrNo
' Click on (OK]
window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

' Verify the Orderno displayed in Flight Reservation


OrdNo l =window("Flight Reservation").\VinEdit("Order No:").GetROProperty("text")
IfOrdNo = OrdNol Then
s Reporter.ReportEvent micPass ,"Verifying the Order No ","Order No is displayed
Properly"
else
Reporter.ReportEvent micFail ,"Verifying the Order No ","Order No is Not displayed
Properly"
End If
'Close the application
Window ("Flight Reservation'').Close

1:
- ,.-
,-.-

~------

;
Page 45 of 118 ~
8 MrVenkat (Sr. Test Manager) '~
!
Test Scenario 3:
1. Enter Input 1 & Input 2 Values
2. Click on [OK]
3. Check Result
4. Display Results in Quick Test Print ID
5. 10 Times

'"' MUlTIPLY [)@) ')(

Far ,·-= I -to 16 . Sl£-p

X ::: i·l)puJ box ( tl fuJ.ey 1hpq tl j


y = i"'{Ju~ hox (_ u [ ~ f nputJ. ~
f..J:VJda.,.J (_ r). ~~·neJ...;~: ('\lr>p<ftl rJ. s~t F
l\ rf\4./-1-ip!J

W•"d,"' ('' "'-« /h.P,i'( ''.)· ._,;hed."t ( ,, II'JP~H'). Sef y


)c

t-
r--
E
. t..J;'IdeuJ (_ \I M~l+i Pt} IV. w·;~\! ~ c II ('J k. !J j. diJ.._ I
i
W; v, ~ \1 ""-t/ h. pi_J
1
1) · h o\e./_;f: (_" Ce S 4. lt ':)- Ce d V", s; b/ey ex!(_ J ·-·-
Ll

t;

rr c;li(£cj ~ c_:cJ- C>J ~ c_.·...t c.':[) ~

l
__
i

, :-

,...--
i '
!f----

'
·~·
n -

~~

I
-~-
~
,,
'

- "- -

Mr. Venkat (Sr. Test Manager)


~-
Page 46 of 1 18 ~~...
.. u

~
!
Data Driven Test
Parameterization
>- Data driven: Running the test with multiple set of data
>- Parameterization: It is a variable that is assigned a value from various data sources or
generator.
Parameter types:
1. Data table }
2. Environment variable Standard Parameter types
3. Random number

4. Database
5. Text files } Advanced Parameter types
6. Excel files

1. Data table
>- QTP enables you to create and run tests, which are driven by data stored in table
>- It is used to store the data and parameterize that data to the test script
>- There are two Sheets by default. (1) Global (2) Action 1
> In one data table we will have 256 Sheets. Out of 256 sheets, one sheet is Global and
remaining 255 sheets are Action Sheets.
>- Two types ofData table
1. Design Time Data Table
2. Run Time Data Table

I Difference between Design Time Data Table & Run Time D'1ta Table
I Design time Dat'1 Table I Run Time D~1ta Table
l j It is vie\ved in the QTP lvfain
-- ---·rr-e.s-t:- ----- -·---··-·--·-------·---·-·- -- ---·---------------- - 1j It is viewed in the QTP --------n{es~-----·-----------·--------·
Test
. -----·.

... . ·- 2j, It___ is_________created


- ............ .... .,
prior
____________
:-·····-·--"'"" ___ to,
the test .......---,
______________________
, _______ .. I~ It is created. in Test Results
I
______ .. __ after
.. ____ .. ___ _.
. . , .,

/e~eC11tlQJ1. · Ityst executiOn.


" I

3) It represents d::~ta from extemal · . JHt represents a live version of__


I···· - ------ - - -·-$()\lJC~s.- --________ . _ _ --·- ·-·- - - - ------·- ----·------ ---·-· -----·- rd.~s-1ii1-t1i11e-nat<1tal1le.----- -- -··-·-

Create Data driven tests using Data Table


> When you test your application, you may want to check how it performs the same operations
with multiple sets of data.
> For example,
> Suppose you want to check how your application responds to ten separate sets of data. You _,_
could record ten separate tests, each with its own set of data.
Alternatively,
> You could create a data-driven test with a loop that runs ten times.

8 t----

Mr.Venkat (Sr. Test Manager) Page 47 of 118 L -


~ ••: Mn••

i
~liveTech
· liuFj llslinn wf•tio.,

1. Design time Data Table


Steps for Parameterization I
1. Create Test I Pro gram l
!
2. Defining a Design time Data Table Parameters
3. Adding Parameter Values to a Data Table using Keyword view
4. Running and Analyzing a Parameterized Test
r
Parameterize a Step
~ In the Keyword View, click in the Value cell of the step and then click the parameterization
ICOn.

: JmAgentName: · -:·- ,Set IMJMI!t ... Enter "mercur}J" in the "Agent Name:" edit box.

Results

~
~ After running a test, we can view a report of major events that occurred during the test run.
~ If any iteration is failed report it as a defect using Quality Center 10.0 I Bugzilla 3.2.
~---

i!
2. Run Time Data table (Using Data Table Methods)
I
r
I
Data Table Methods
!
f
I
1. Add Sheet: !
i
I
[:;

We can use this method to "add" one new sheet to the run time data table. I ~
I
f
Syntax: datatable.AddSheet ("Sheet_Name") I

Ex : datatable.AddSheet ("input")
I
!
2. Delete : i
We can use this method to "delete" one specified sheet from the Run Time Data tablP. '
Syntax: datatable.DeleteSheet (Sheet_ID)
Ex : datatable.DeleteSheet (3)

3. GetSheetCount :
I --
r-
~
lr

We can use this method to count number of sheets in the run time data table. r-- iJ

Syntax: datatable.GetSheetCount ~'-


I'
~
Ex : msgbox datatable.GetSheetCount

4. GetRowCount:
We can use this method to count number of rows in the 1st sheet of the Run tii"e data table.
r----
,
L-
Mr.Venkat (Sr. Test Manager) Page 48 of 118 L___
~

!
~liveTech
finfy sdltions
ltsfiiR

Syntax: datatable.GetRowCount
Ex : msgbox datatable. GetRowCount

5. GetSheet:
We can use this method to return a specified sheet from the Run Time data table.
Syntax : datatable.GetSheet(SheetiD)
' I--
Ex : msgbox datatable.GetSheet(l).GetRowCount
ation
6. Value:

- We can use this method to set or get value of cell in the specified parameter and the current row
of the Run time data table.
To get data
Syntax:
Variable= datatable.Value(Parameter_Name, Sheet_Name)
or
Variable= datatable(Parameter_Name, Sheet_Name)
To set data:
Syntax:
datatable.Value(Parameter_Name, Sheet_Name) =Value I variable
or
datatable(Parameter_Name, Sheet_Name) =Value I variable
Ex:
a=datatable.Value (1, 1)
un. b=datatable. Value (2, 1)
c=cint( a)+cint(b)
datatable. Value (3, 1) = c
7. SetCurrentRow
We can use this method to take a specified row as current row in the Run Time Datatable (By
default it is 1st Row of 1st Sheet)
Syntax: datatable.SetCurrentRow(Row Number)
Ex: s="sairam"
datatable.SetCurrentRow (3)
datatable. Value (1, 1) = s

8. SetNextRow
We can use this method to take the row a~er the current Row as New Current Row in the Run
time data table.
Syntax; data table. SetN extRow
Ex: s="sairam"
datatable.SetCurrentRow (3)
r-----
datatable.SetNextRow
datatable.Value (1,1) = s
r---
..,

f-·-
9. SetPrevRow I!

We can use this method to take the row before the current Row as New Current Row in the Run r--
~
time data table.
Syntax: datatable.SetPrevRow

18
Mr.Venkat (Sr. Test Manager) Page 49 of 118 f-----
r-·---
f[
~liveTech
fU,tfyltstiiJoS<!Illti..s

Ex: s="sairam"
datatable.SetCurrentRow (3) I
I-
datatable.SetPrevRow I
datatable.Value (1,1) = s
10. Import
We can use this method to import Microsoft Excel File to the Runtime Data Table (Including all
t t-
sheets)
·Syntax: datatable.Import "Path of File"
Ex
lmportSheet
: datatable.Import "F:\Inputdata.xls"

We can use this method to import a specified sheet of Microsoft Excel Sheet to the Runtime Data
f
!
l
!
table. I
Syntax : datatable.ImportSheet "Path of File", "Source Sheet", "Destination Sheet" '
Ex : datatable.ImportSheet "F:\Inputdata.xls",3,1 t
11. Export [
. !
We can use this method to export a copy of Run Time Data table to another location (Including '·
i
all sheets) .1
Syntax : datatable.Export "Path of File" ·
{
Ex : datatable.Export "F:\Outputdata.xls" i
~~~ I
We can use this method to export a copy specified sheet of Run Time Data table to the [
existing or new Excel File. l
Syntax: datatable.ExportSheet "Path of File", "Sheet Name I Source Sheet" ''
Ex : datatable.ExportSheet "F:\Outputdata.xls", 2

Scripts using Datatable


1. Create a script for Flight Reservation Login and taking login credentials from Runtime
Data table
2. Verify Calculation Test
3. Verify Flight Reservation Orders
4. Prepare script for [Update Order] behavior, When we open an Order (Update Order]
should be disabled
5. Create a script for Project Login and taking login credentials from Runtime Data table

Test Scenario 1:
Create a script for Flight Reservation Login and taking login credentials from Runtime
Data table.
Steps:
1. Create Folder Structure _r;_

Framework ~ Repository, Test Data, Test Script and Test Log


2. Create "Login.xls" and copy into "TestData" folder (AgentName, Password and Test Result)
3. Create Object Repository and Export into Repository folder and Associate Repository t--
ti

4. Create Script
5. Enter Login values and Run Script
6. Observe "TestLog" folder for Test Resutls

Mr.Venkat (Sr. Test Manager) Page 50 of 118 _,_


!=
f
f
f

I
(
Option Explicit
Dim RowCount, i

l Datatable.AddSheet "Input"
-. __

f Datatable.ImportSheet "C:\QTP_ Examples\WBMS\Frameworks\Test Data\Login.xls", 1, "Input" . ~-


all
RowCount= Datatable.GetSheet("Input").GetRowCount

I! For i=1 to RowCount Step 1


I
lata II Datatable.SetCurrentRow(i)
I
l' Systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
'
Dialog("Login").WinEdit("Agent Name: ").Set Datatable.Value("AgentN arne", "Input")
g Dialog("Login").WinEdit("Password:").Set Datatable.Value("Password","Input")
Dialog("Login").WinButton("OK").Click

If window("Flight Reservation").exist Then


Reporter.ReportEvent micPass, "Verify Login","Test is Pass"
Datatable.Value("TestResult", "Input")="Test is Pass"

else
Window("Flight Reservation").Close
I
Reporter.ReportEvent micFail, "Verify Login","Test is Fail"
Datatable.Value("TestResult", "Input")="Test is Fail"
Dialog("Login").Dialog("Flight Reservations").WinButton("OK").Click
f:
i
ne Dialog("Login").WinButton("Cancel").Click r---
End If ~

f
l
Next
I,-,-
~

'Export Results to Test Log ~


Datatable.ExportSheet "C:\QTP _Examples\WBMS\Frameworks\Test Log\Result2.xls;',"Input"

Test Scenario2:
Conduct Data Driven Test on for Flight Reservation calculation test using Runtime Data
table.

Option Explicit '-~-


Dim RowCount,i,OrdNo,Tickets,Price,Prc,Total,Tot r----
F.--

Datatable.AddSheet "Input"
Datatable.AddSheet "Output"

Datatable.GetSheet("Output").AddParameter "OrderNumber",""
Datatable.GetSheet("Output").AddParameter "Tickets",""
,.___ _
r-=---
i---
Page 51 of 118
~~ Mr.Venkat (Sr. Test Manager)
~liveTech
fkelj lesli•!1wf•ti•n.

Datatable.GetSheet("Output").AddParameter "Price",""
Datatable. GetSheet("Output").AddParameter "Total",""
Datatable. Get~heet("Output") .AddParameter "TestResult","" I
Datatable.ImportSheet "C:\QTP_Exflmples\WBMS\Frameworks\Test
Data\Input.xls","Sheetl ","Input" I ~---

RowCount= Datatable. GetSheet("Input"). GetRowCount

For i=l to RowCount Step 1

Datatable.SetCurrentRow(i)
II
(
OrdNo=Datatable.Value("OrderNumbers","Input")
Window(" Flight Reservation") .Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order... "
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No. ").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrdNo
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

Tickets= Window("Flight Reservation").WinEdit("Tickets:").GetVisibleText()

Price=Window("Flight Reservation").WinEdit("Price:").GetVisibleText()
Pre= mid(Price,2,len(Price)-1)
Total=Window("Flight Reservation"). WinEdit("Total: ").Get Visibl eT ext()
Tot=mid(Total,2,len(Total)-I)

If Cint(Tickets)*cdbl(Prc)=cdbl(Tot) Then
Reporter.ReportEvent micPass, "Verify Total","Calculation Test is Pass"
Datatable. Value("OrderNumber"," Output")=OrdNo
Datatable. Value("Tickets", "Output")=Tickets
Datatable. Value("Price", "Output")=Prc
Datatable.ValueC'Total","Output")=Tot
Datatable. Value("TestResult", "Output")="Test is Pass"
else
Reporter.ReportEvent micFail, "Verify Total","Calculation Test is Fail"
Datatable.Valqe("OrderNumber","Output")=OrdNo
Datatable. Value("Tickets", ''Output")=Tickets
Datatable.Value("Price","Output")=Prc
Datatable. Vafue("Total", "Output")=Tot
Datatable.Value("TestResult","Output")="Test is Fail"
End If
~-----

~
Next ~
~
,.
'Export Results to TestLog folder
Datatable.ExportSheet "C:\QTP_Examples\ WBMS\F rameworks\Test
Lo g\CalculationResult.xls", "Output"

r--
~

L__
Mr.Venkat (Sr. Test Manager) Page 52 of 118 t==-
!
II Test Scenario 3:
f
t
!
Verify Flight Reservation Orders
! Option Explicit
I
I
I
Dim RowCount,i,OrderNumber, OrdN o

Datatable.AddSheet "Input" I-
I
i

I
I
Datatable.ImportSheet "C:\QTP_Examples\Test Data\Orders.xls","Input","Input"
RowCount= Datatable. GetSheet("Input "). GetRowCount

For i=1 to RowCount Step 1


Datatable.SetCurrentRow(i)
I OrderNumber=Datatable.Value("OrderNumber","Input")

I
I
i
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No. ").Set "ON"
Window("Flight Reservation").Dialog("Open Order"). WinEdit("Edit").Set OrderNumber
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
i
I OrdNo=Window("Flight Reservation").WinEdit("Order No:").GetVisibleText()
f

I If OrdNo=OrderNumber Then
Reporter.ReportEvent micPass, "Verify Order","Test is Pass"
I Datatable.Value("TestResult","Input")="Test is Pass"
j

1
else
Reporter.ReportEvent micFail, "Verify Order","Test is Fail"
I
I
I
Datatable.Value("TestResult","Input")="Test is Fail"
End If -
Next
t=
I
r--
I
'Export Results to "TestLog"
I
I
Datatable.ExportSheet "C:\QTP _Examples\Test Log\OrderResults.xls", "Input"

I Test Scenario 4: f
Prepare script for [Update Order] behaviour, When we open an Order [Update Order] ""
~
should be disabled. (Conduct data driven test)
Option Explicit
Dim Ro}vCount,i,OrderNumber,strMsg

I Datatable.AddSheet "Input"

I Datatable.ImportSheet "C:\QTP_ Examp1es\WBMS\Frarrieworks\Test Data\Orders.xls", 1,3

RowCount= Datatable. GetSheet(3 ). GetRowCount


I For i=1 to RowCount Step 1
Datatab 1e. SetCurrentRow(i)
OrderNumber=Datatable.Value("OrderNumber",3)

I Window("Flight Reservation").WinMenu("Menu").Select "File; Open Order..."


Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight-Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNumber
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

Mr.Venkat (Sr. Test Manager) Page 53 of 118


strMsg=Window("Flight Reservation").WinButton("Update Order").GetROProperty("enabled")

IfstrMsg="false" Then
Reporter.ReportEvent micPass,"VerifY UpdateOrder","Update Order is Disabled, Test is Pass"'

else
Datatable.Value("TestResult",3)="Test is Pass" J--
Reporter.ReportEvent micFail,"Verify UpdateOrder","Update Order is Enabled, Test is Fail"
Datatable.Value("TestResult",3)="Test is Fail"
End If
Next
'Export Results
Datatable.ExportSheet "C:\QTP_Examples\Frameworks\Test Log\UpdateResults.xls", 3

Test Scenario 5:
Create a script for Project Login and taking login credentials from Runtime Data table

r-
~---

~
~

~!--

Mr.Venknt (Sr. Test Mnnngcr) P:1gc 54 of 118


I
I
l
~livelech
') I
II
I
Bvtfy ustinoso6t!Wns

2. Environment Variable

!
Environment Variables are two types such as

' 1. Built-in-variable
! 2. User defined variable
I
f
[
' 1. Built-in-variable
1
f' It represents the information about the Test and the system in which the test is running.
r
f
Ex:
f
f 1. Environment.Value ("OS") (It will display Operating System)
I
(
I
2. Environment.Value ("OSVersion") (It will display operating system version)
! 3. Environment.Value ("LocalHostName") (It will display Local Host Name)
i
} 4. Environment. Value ("Test Name") (It will display Test Name)
f
f 2. User defined variable
l
I
I Method 1:
i
I File 0 SettingsO Environment 0 Variable type 0 Select User defined
J ~ Click on Add(+)
!

~ Enter variable name and value and click on [Ok]


Retrieving variables using Keyword View:
1. Go to Keyword view and Select value configurations window
2. Select Parameter as "Environment"
3. Select Name and Value and click on [Ok]
Method 2:
1. External Variables will be present in the ".xml" file and we can associate this 'xml' file to the
test to use those variables in any action of that test.
2. To create 'xml' file with required variables we can prepare script likes as below.
3. Open Notepad ->Prepare script like as below -> Save the file with '.xml' extension.
<Environment>
<Variable>
<Name>usemame</N arne>
<Value>pmc<N alue>
<Nariable>
<Variable>
<N ame>password</N arne>
<Value>pmc<N alue>
<N ariable> ·
</Environment>
How to associate .xml file to Test before execution: _:\_
Navigation: _
[ -
rr- ------
1. File-> Settings-> Environment 0 Variable type (User Defined One) 0 Select '·Load variables :1
and Values from external file" 0 Browse and Select .xml file and click on [Ok] ati-~­
(or)
2. How to associate .xml file during Runtime Syntax
Environment.LoadFromFile "Path ofXML file''
Retrieving Environment Variables in QTP Test:
Environment. Value("U semame")
"--
~ --

~----
Mr.Venkat (Sr. Test Manager) Page 55 of 118 r=------
1
~liveTech
liury ttsliiJI Sd!•tW.•

Test Scenario 1:
Create a script for Project Login and taking login credentials (URL, Username and
Password) from Environment variables.

1. Create an XML file with values ofURL,Username and Password.


2. Associate XML file to QTP test

• Systemutil.Run Environment.Value("StrURL")
• Browser("PMC Inc. ").Page("PMC Inc. ").WebEdit("Userld").Set Enviromnent. Value("Userld")
• Browser("PMC Inc. ").Page("PMC lnc.").WebEdit("Password").Set Environment.Value("Password")
• Browser("PMC Inc. ").Page("PMC Inc. ").WebButton("Submit").Click
• Browser("PMC Inc.").CloseA11Tabs

Test Scenario 2:
Create a script for Flight Reservation Login and taking login credentials (URL, Username
and Password) from Environment variables.
XML File and Script:

3. Randon1 Number ~"-


~ ---

1. Go to Keyword view and Select value configurations window


2. Select Parameter as "Random Number"
3. Enter Numeric range From as "1" and To as "9" and Click on [Ok)

Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set RandomNumber( I, 100)

:=--------

Mr.Venkat (Sr. Test Manager) Page 56 of 118 ~-· -


f
~llveTech

d
I r
1
fwtfy ttsli/Jg sdlili<»Js

4. Database (Advanced Parameter Types)


( 1. VB Script is Object Based Language
I 2. It doesn't support external files directly, When we want work External files and we ne~d to
Create Object .

II i
3. External files are Database, Text files, Excel files and Word ... etc.,

Syntax:
Set Objectname=CreateObject("Servemame.Classname")
Servemame = ADODB
J
I Classes are:
r
r 1. Connection
'[
2. Command
f 3. Recordset
i
l'
I 1. Connection
i
We can use this class to establish a connection to the specified database during Runtime
Syntax:
Set ObjCon = CreateObject("ADODB.Connection")
ObjCon.open "Provider-Provider Name"
Example:
'0 MSAccess
ObjCon.open "Provider-Microsoft.Jet.OLEDB.4.0;Data Source=Path ofDatabase"
)
SOL Server
ObjCon.open "Provider-sqloledb.l; Server=IP Address; uid=Usemame; pwd=xxx; ·
database=database name"

Oracle
ObjCon.open "Provider=oraoledb.l; Server=xxx;
useriD= U semame(scott); password=xxx( tiger)"
Note:
1. ADODB means Activex data object database
l 2. oledb Object linking embedded database
i Note:.
I To get provider Name
i 1. Open Notepad ~ Save empty file with .udl extension
2. Open that udl File~ Provider Tab~ Select Provider -7 Next -7 Select Database -7
I Test Connection ~ Click Ok -7 Click Ok
3. Open same file in Notepad and copy Provider Name to Script f---
~
2. Command ~­
~
We can use this class to execute specified DML Statements (Insert, Update, Delete) on r;
~
connected database.
Code:
Set ObjCom=createObject ("ADODB.Command")

Mr.Venkat (Sr. Test Manager) Page 57 of 118


ObjCom.ActiveConnection = conobj
ObjCom.CommandText = "SQL Statement"
J
i
ObjCom.Execute
3. Recordset
l
We can use this class to execute specified select statement on connected database and
retrieve the results.
Code:
Set ObjRS = createObject ("ADODB.recordset")
I
(
4. Nothing
ObjRS.open "SQL Statement", conobj
I
Noting is a keyword in VB Script, which is used to disassociate an object variable from the
actual object. l
Code: I
Set objectname = nothing I

Create MS Access Database- Test Pun..1ose


Navigation:
1. Start~ Programs~ Microsoft Office-7 MSAccess
2. File~ New~ Blank Database~ Enter Database name "SampleDB" and [Creaie]
3. Click on 'Create Table in Design View'
4. Enter Field names as Usemame and Password and click on (Save]
5. Enter table name as 'Login' and click on [Ok]

Script 1:
How to set data into database table
Option Explicit
Dim ObjCon,ObjCom

Set ObjCon=CreateObject("ADODB.Connection")
ObjCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\QTP_Examples\WBMS\Others\SampleDB.mdb;Persist Security Info=False"

Set ObjCom=CreateObject(" ADODB.Conunand")


ObjCom .ActiveConnection=Obj Con

ObjCom.CommandText ="Insert into Login values('Venkat','mercury')"


ObjCom.Execute

ObjCon.Close

Set ObjCom=nothing
Set ObjCon=nothing t-----

.~ ___
Fmu

Mr.Venkat (Sr. Test Manager) [L _ _ -

Page 58 of 118 ,. ·- -···:

!
~LiveTech
usti•n "''"ti""'
firtfy

Script 2:
How to set multiple records into database table by taking the data from Excel file

Option Explicit
Dim ObjCon,ObjCom, RowCount,i,Uname,Pwd

Set ObjCon=CreateObject("ADODB.Connection")
ObjCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\QTP_ Examples\WBMS\Others\SampleDB.mdb;Persist Security Info= False"

Set ObjCom=CreateObject("ADODB.Command")
Obj Com.ActiveConnection=Obj Con

Datatable.AddSheet "Input"
Datatable.ImportSheet "C:\QTP_ Examples\WBMS\Frameworks\Test
Data\Login.xls","Sheetl ","Input"

RowCount=Datatable.GetSheet("lnput").GetRowCount

For i=1 to RowCount Step 1


L
Datatable.SetCurrentRow(i)

Uname=Datatable.Value(" AgentN arne", "Input")


Pwd=Datatable.Value("Password","Input")

ObjCom.CommandText ="Insert into Login values("'&Uname&'","'&Pwd&"')"


ObjCom.Execute

Next

ObjCon.Close

Set QbjCom=--nothing
Set ObjCon=nothing

Script 3: I :!

'How to get data from the dat:1b:1sc table l


'
!
;,
'"

·.
:, :\
l :;
Option Explicit l ~--
Dim ObjCon,ObjRs,Var

Set ObjCon=CreateObject("ADODB.Conncction")
··!! i~
j
I

ObjCon.Open "Providcr==l\1:::·osotUet.OLEDB.4.0:D:It~l i

Source=C:\QTP _Examples\\VBMS\Others\SnmplcDB .mclb;Pcrsist Security Info= False"


Set ObjRs=CreateObject("ADODB.Recordset") I
I~
1-.-
! c.:_--=-=-=-
·1 '
I ~
Page 59 of 118 ~ In••-
Mr.Venkat (Sr. Test Mannger) I
' ,. ....:-.-c
~
~ ~
ObjRs.Open "Select* from Login",ObjCon
ObjRs.MoveFirst

While not ObjRs.EOF


Var=ObjRs("U sername")
Print Var
ObjRs.MoveNext
Wend

ObjRs.Close
ObjCon.Close
Set ObjRs=nothing
Set ObjCon=nothing

Script 4:
Verify Login using data from Data base

Option Explicit
Dim ObjCon,ObjRs,Uname,Pwd

Set ObjCon=CreateObject("ADODB.Connection")
ObjCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\QTP_ Examples\WBMS\Others\SampleDB.mdb;Persist Security Info=False"

Set ObjRs=CreateObject("ADODB.Recordset")
ObjRs.Open "Select* from Login", ObjCon

ObjRs.MoveFirst

While not ObjRs.EOF


Unnme=ObjRs("Usernnmc")
Pwcl=ObjRs(" Password")

Sy~~t cmut i I. Run "C: \I; t·u g1·;1 ::1 Fi lcs\1·1 P\Ql! i ck'T'csl 11 mtession:ll\!l ight\app\!l ight4a.cxc"
Di;llog("L,;gitl").WiJ:Lclit("A:;t~'ll !'\:::11c:").Sc:t Ln:!t~ic:
Di:tlog(" l.ugin"). Wint:-:di!("P:tss\'..-oJ·ci:") . .:.;L·l Jlwd
D i :1l ~ '!;/'' L~:_~_i 1: ").\Vi:: ~j lil :, '11( "0 K ").CI i ~.·k

11.\Vindo\'.'("lTgilt l~csct·\·:lliun").!:xiq Ti1C'i1

Reporter. 1-Zcpori [n·nl mi~l):1ss, "\' ui l\· L.u~~.in'',"T ~st is 1':1ss" "-,;-
p1·int "Login :;~:~cc:->s" '
.;

wi nclow(" Fl i gh l P. cscrv:1l inn"). C! n: ~.:


else
Rcportcr.Rcp.·~·t[>-'L'lll micF:1i!, "V c1 i l\:
.
L\):.;in","Tc:st is Fail".
print "Login F:lilcc\''
Dialog(" Logi 11 "). D i :dog(" fl igh! l~ cscrval io11S"). Wi nButton("OK").Ciick

r-----
i.
~
Mr.Vcnkat (Sr. Test Manager) Page 60 of 118 ~
"--"--
Dialog("Login "). WinButton("Cancel ").Click
End If
ObjRs.MoveNext
Wend
ObjRs.Close
ObjCon.Close
Set ObjRs=nothing
Set ObjCon=nothing

l Script 5:
I 'Data Base Testing

Option Explicit

I,
Dim RowCount,i, CN arne, Tickets, ObjCon, ObjRS, OrdN o

Datatable.AddSheet("Input")
Datatable.ImportSheet "C:\12315\WBMS Framework\Test
Data\Customers.xls", "Sheet I ","Input"

I
I
I
RowCount=Datatable.GetSheet("Input").GetRowCount

Set ObjCon=CreateObject("ADODB.Connection")
ObjCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program
~
I.-
Files\HP\QuickTest Professional\samples\flight\app\flight32.mdb;Persist Security Info=False"
I
c
~
For i=l to RowCount Step l
I Datatable.SetCurrentRow( i)

I
CN ame=Datatable. V alue("CustomerN ame", "Input")
Tickets=Datatable.Value("Tickets", "Input")

Window("Flight Reservation").Activate
Window("Flight Reservation'').WinMenu("Menu").Select "File;New Order"
Window("Flight Reservation").ActiveX("MaskEdBox").Type "111112"
Wi~dow("Flight Reservation").WinComboBox("Fly From:").Select "Frankfurt"
'
L__
'~

I Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"


Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "20331 FRA
09:12AM LAX 04:23PM AA $112.20"
V..'indow("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click
Window("Flight Reservation"). WinEdit("Name: ").Set CN arne l~
Window("Flight Reservation").WinEdit("Tickets:").Set Tickets t_
~~
Window("Flight Reservation").\VinButton("Insert Order").Click
Window("Flight Reservation").ActiveX("Threed Panel Control").WaitProperty "text", "Insert i-
'

Done... ", 20000


OrdNo=Window("Flight Reservation").WinEdit("Order No:").GetROProperty("text")

8 ~-

Mr.Venkat (Sr. Test Manager) Page 61 of 118 ~


f --
Set ObjRS=CreateObject(" ADOD B.RecordSet")
ObjRS.Open "Select* from Orders where Order_Number="&OrdNo,ObjCon

If ObjRS("Customer_ Name")=CN arne Then


Print "DB Testing Pass"
else
Print "DB Testing Fail"
End If

Next

Obj Con. Close

Set ObjRS=nothing
Set ObjCon=nothing

Script 6:
Oracle Example- Project Data

Option Explicit
Dim ObjCon,ObjRS

Set ObjCon=CreateObject("ADODB.Connection")
ObjCon.Open "Provider=MSDASQL.l ;Password=wbms;Persist Security Info=True;User
ID=wbms;Data Source=wbms"

Set ObjRS=CreateObject("ADODB.RecordSet")
ObjRS.Open "Select* from user_tbi",ObjCon

ObjRS.MoveFirst

While not ObjRS.EOF


msgbox ObjRS("UNAME")
ObjRS.MoveNext
Wend

ObjCon.Close

Set ObjRS=nothing
Set ObjCon=nothing
r
r-- -
~
i!
tL__
'
g

F----=-=--=--:
t__ -- -
Mr.Yenkat (Sr. Test Manager) Page 62 of 118 [ om••- ·:

!'
l

5. File System Object (FSO)(Text Files)

>- This is one of the objects provided by the VB Script.


~ We can create folders, files in our Machine.
r,.J,
Syntax: 1 't:· L
Set ObjectName ==CreateObject("Scripting.FileSystemObject") :r ,
Set ObjFSO ==CreateObject("Scripting.FileSystemObject") ·~ ,j-:
.
To Create a folder: '~

ObjFSO.createFolder("C:\LiveTech")
To Create a file:
ObjFSO.createTextFile("C:\LiveTech\Testing.txt")

To write the Data into text file


Set objFSol =objFSO.Createtextfile("C:\LiveTech\Testing.txt")
This object holds the path of the text file

I
objFSO 1. write line "LiveTech is a G0od Testing institute"
objFSOl.writeline "LiveTech is in Ameerpet"
To close the Opened file (Which we are opened for writing the Data)
objFSOl.Close

I To Delete the Folder file:


obj FSO .Deletefolder(" ----path----")
obj FSo .Deletefi le(" ----path----")
To Delete the Object:
Set ObjFSO==Nothing
This object is going to Delete.

Script 1:
How to Create Folders, Files and Test Data
Set ObjFSO ==CreateObject("Scripting.FileSystemObject")
ObjFSO.createFolder("C:\LiveTech")
ObjFSO.createTextFile("C:\LiveTech\Testing.txt")

II
Set abc=ObjFSO.CreateTextFile("C:\LiveTech\Testing.txt")
'This object holds the path of the text file
abc.writeline "LiveTech is a Good Testing institute"
abc.writeline "LiveTech is in Ameerpet"

I Flat File:

I •

Some times we are conducting data driven testing depending on multiple test data from "Text" files .
To manipulate flat file content for testing we can prepare script like as below .
Set fso = createobject("Scrpiting.filesystemobject")
Set f=fso.opentextfile ("Path of text file", mode[Read-1, Write-2, Append-S])
while f.atEndOfline == false . t---

s==f. readline
f
r:

............ sets

~-:__:____
Mr.Venkat (Sr. Test Manager) Page 63 of 118 ~
.~.~

f ...
Wend
fclose

Script 2:
Login using Data from Text File:

'Create a text file with values of password and save into C:\
Option Explicit
Dim ObjFSO,ObjRD,User

Set ObjFSO = createobject("Scripting.filesystemobject")


Set ObjRD=ObjFSO.Opentextfile ("C:\LiveTech\Testing.txt",l)

While ObjRD.atEndOfline =false

User=ObjRD.readline

Systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

Dialog("Login'').WinEdit("Agent Name:").Set User


Dia1og("Login").WinEdit("Password:").Set User
Dialog("Login "). WinButtofl("OK ").Click

Window("Flight Reservation").Close

Wend

ObjRD.close
I
Set ObjRD=nothing
Set ObjFSO=nothing

QTP More Methods: I


1. GetitemsCount()
2. Getltem()
L
"
r:
~
3. GetContent()

1. GetltemsCqunt
We can use this method to count number of items in the Combo bo:x/List Box.

2. Get!t'ml
We can use this method to get a specified item from the Combo Box

3. GetContent ~
~ --

We can use this method to get content of the Compo Box.

Mr.Venkat (Sr. Test Manager) i_ _


Page 64 of 118 ~'­
o:..:=.::.:
!
Script 3:
Example for GetltemsCount(), Getltem() and GetContent()

Option Explicit
Dim Itemscount, Item_Flyfrom,Contect-Flyfrom

Itemscount_Flyfrom=window("Flight Reservation").WinComboBox("Fly From:").GetltemsCount()


Item_Flyfrom=window("Flight Reservation").WinComboBox("Fly From:").Getltem(l)
Content_Flyfrom=window("Fl ight Reservation") .WinComboBox("Fly From:"). GetContent()
print ltemscount_Flyfrom
print ltem_Flyfrom
print Content_Flyfrom

Script 4.
How to count number of items in the Fly From Combo Box and bow to display their name one by
one.

Option Explicit
Dim ltemCount,i,ItemVal

ltemCount=Window("Flight Reservation").WinComboBox("Fly From:").GetltemsCount()

For i=O to ItemCount-1 Step 1


ItemVal=window("Flight Reservation").WinComboBox("Fly From:").Getltem(i)

Print ItemVal
Next

Script 5:
How to display FlyFrom Combo Box items one by one into Notepad Option Explicit

Option Explicit
Dim ObjFSO,Obj\VL,ltemCount,i, ItemVal

Set ObjFSO=CreateObject(''Scripting.FileSystemObject")
Set ObjWL=ObjFSO.OpenTextFile("C:\LiveTech\FlyFrom.txt",2)

ltemCount=Window("Flight Reservation").WinComboBox("Fly From:").GetltemsCount()

For i=O to ItemCount-1 Step 1


ItemVal=window("Flight Reservation"). WinComboBox("Fly From:").Getltem(i)
ObjWL.Writeline ItemVal
Next

ObjWL.Close '
,-_,-
~

Set ObjWL=nothing
Set ObjFSO=nothing

~-
Page 65 of 118 ~~-

Mr.Venkat (Sr. Test Manager) r=


ij
Script 6:
How to display Flyfrom Combo box items one by one into Runtime Data table and the same data
table export to Excel Sheet

Option Explicit
Dim ObjFSO,ObjWL,ItemCount,i, ItemVal

Datatable.AddSheet "Output"
Datatable. GetSheet("Output").AddParameter "FlyFrom", ""

ItemCount=Window("Flight Reservation").WinComboBox("Fly From:").GetitemsCount()

For i=O to ItemCount-1 Step 1


Datatable. SetCurrentRow(i+ 1)
Item Val=window("Flight Reservation").WinComboBox("Fly From: ").Getltem(i)
Datatable. Value("FlyFrom", "Output")=Item Val

Next

Datatable.ExportSheet "C:\QTP_Examples\ WBMS\Frameworks\Test Log\FlightLocation.xls" ,"Output"

Script 7:
How to verify update Order behavior in the Flight reservation application and how to pass multiple
values from the text me - File System Object(Text Files)

Option Explicit
Dim fso,f,s,arr,strStatus

Set fso=CreateObject("Scripting.filesystemobject")
set f=fso.OpenTextFile("E:\Records.txt", I)

While not f.AtEndOfStream

s=f.ReadLine
an-=split(s." ")
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order... "
Window(" Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window(" Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set arr(l)
Window(" Flight Reservation").Dialog("Open Order").WinButton("OK").Click
strStatus = Windmv("Flight Reservation").WinButton("Update Order").GetROProperty("Enabled")

If strStatus="False'' Then · ::
Reporter.ReportEvent micPass,"Update is Disabled","Test is pass" C<

~
Else ~------

Reporter.ReportEvent micFail,"Update is Enabled","Test id failed"


End If t-
r,
·-:-

\Vend
f. Close
Set fso=nothing

Mr.Venkat (Sr. Test Manager) Page 66 of 118


~liveTech
finry "'''ti"•• ttsrinn

6. Excel Files
Excel Object:
)> This is one of the objects provided by the VB Script.
)> We can create Excel files, Workbooks, Sheets and Colors in our Machine.
Syntax:
Set Object Name= Createobject ("Excel.application")
Set objExcel=Createobject ("Excel.application")

Script 1:
How to create below excel file and how to save in framework folder

A I B c
_1_ l11pt1t 1 J!•.~p~~1? Result
_1_ -~ -----t
; - +- · _· · · · _· · · · _·-· · ~-· · · _· · · · _· · · · _· · · ·_· · · · _· · · ·-+· t
,_· · _· · _· · _·_·_

set obJExce.l ~ c~aleC!qJecl:C ll ex.ce.L· AppU c_o.h'cn ':J


ol<J· [xcel_-v,·..s·ble_ =t-?Ue
GbJucel· "'--ovkhouKS ·A d..d.___
Sci obJ~hE?ef: ~ obiCxce.(· Acll've.Sheel:
a~jSheei · cel/.s CiJ •) == Lt !npu-1:: 111

.S£1 c.\~.ice.U ' ::: 0 1..: , ~~ .


CAJ ,s "'t'et-.. eel t;.( 0
I
. 1J
c~ c~u 1 , f~. c
. o
l
or .:-::. v bBilte_
chJcS~' ce)lr
l0
(_ ·J- ~ npuc ...:L ;
i
l/ L_ -
ll L I I
~;

" - "-
r
Lc;eJ O~/ ce___LU_ ~ al:JJ s h-e.e±-. - I I r (_
~
- c~ G0

I C bJ· u:.U;;( . 1.=-w . Co I vr ::. V bg l u_ e_


i ob_J··_)~-ec__t:. cc..fl._s ( t;,l)::: 1, f?t;Julf:-'1

o~· ceLJ3 :: ObjtSLrecl . cclls L '/ 0.)


I qkj CLlL ,'3 · F c« · CcJ 1crv ~ vhe; rt?QJJ
..-----
~--------

r-
,

S& obj J.-..J~ =- dhj[:x-cel_. Ach'veJ..Jovkbook.


r-
10

oQ}t-J(3 .. s~.s u c· \ \ 1-3JE \ t;Gpp(YJ(___ \


~y~W&YK\ 1e.o+ ~ \ '[:t_cej£)<'-·XI.S 11

CQj ENe-\· (\?\1 ;~::: - -,.-


=------
Mr.Venkat (Sr. Test Manager) Page 67 of 118
Script 2:
How to validate Update Order behavior and set results into excel file
Set objExcel=Createobject ("Excel.application")
objExcel. Visible=True
objExcel. Workbooks.Add
set objSheet=objExcel.ActiveSheet
objSheet.cells(l, 1)="Status"

set c1=objSheet.cells(1,1)
c 1.font.color=vbblue

Window(" Flight Reservation"). WinMenu("Menu"). Select "File; Open Order..."


Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No. ").Set "ON"
Window("Flight Reservation").Dialog("Open Order"). WinEdit("Edit_2").Set "2"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
strMsg = Window(''Flight Reservation").WinButton("Update
Order"). GetROProperty("Enabled ")
If strMsg="False" Then
Reporter.ReportEvent micPass,"Update is disabled ","Test is Pass"
obj Sheet.cells(2, 1)="Update is disabled "
Set c2=objSheet.cells(2,1)
c2.font.color=vbgreen
else
Reporter.ReportEvent micFail,"Update is Enabled","Test is Fail"
objSheet.cells(2,1)="Update is Enabled"
Set c2=obj Sheet.cells(2, 1)
c2. font.color=vbred
End If
set objWbook=objExcel.ActiveWorkbook
objWbook.SaveAs "E:\Venkat.xls"
objExcel. Quit
Set objExcel=nothing

Script 2:
How to validate Update Order behavior and pass data from excel file

Set objExcel=Createobject("Excel.application")
objExcel. Visible=True
set objBook=objExcel.Workbooks.Open("E:\Demo.xls")
-"-
set objsheet=objBook.ActiveSheet "

for i=2 to objsheet.usedrange.rows.count step 1 ~


i
Var=objsheet.Cells(i, I)

Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order. .. " r-- ------
•~
-~-
~
Mr.Venkat (Sr. Test Manager) Page 68 of 118
I
Window("Flight Reservation").Diaiog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit_2").Set Var
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
strMsg = Window("Flight Reservation").WinButton("Update
Order").GetROProperty("Enabled")
If strMsg="False" Then r·

~'
Reporter.ReportEvent micPass,"Update is disabled ","Test is Pass"

else

Reporter.ReportEvent micFail,"Update is Enabled","Test is Fail"


End If

Next
objExcel. Quit
Set objExcel=nothing

rr
r
i
I~
~

L
~
r:
~r~
~

c
-~i-

:=---
Page 69 of 118 ;;

L_
Mr.Venkat (Sr. Test Manager) ··--··--,.-·
5
!
~:!-~ _,....;;r.-~.. -·"-··
A J,,,; .f?.ri?o'i--';;-.-, ...

Oo:ta. 0-t",·ven Te.s-t ;rJj

~~ced~~!!JPBJ
:-t 1
S k'"'-la..av.,.
_1 Pcvv~,r "ru
"'
~ -~
.-
<
(1)
~ pcJ-o- 6 c.8
occ~,,J-o,~,
oo.- ( vcJ.ce .L Ll.rc.hO?
<AoD'3 6!} hcl'flsJ\ C
CD
-
1
~

~
Doln-l<>bie. - [R.or [ 1€ me.H.,_O<k, - -fl-o oc;he e1-/ jftl
>-:l
~ ="""""' s~/c,eJshe<icfaeJ: e=o cu4Js~f!.o'j
c.et vak.e;Set- v..we; exp.,&s"-tJ
ti
.[V)\I(y-cn~ .)(:~ -~
~ ----------'7\ S Lr;pt;
~ t~tV ~-l€:l· . ( (Uri r1fJ • ) [ - :.. I "'1
v~ ("" '?J
~J
~ -.- PY<IJ>'J e.nv:'rD0oY>e.;J •
..:;,
~WE': Pa.._Jo,., 'Mmbe,- [ Rn (s 14,1-,

seJ: " ~ ("' ~ c v-eoJe &!i e oi:['. ADO OS . cof)·mec_hw, 1) [ " 'i""'-c/ u Oo5 e J
sel: obj Co«l ~ c r&>k Ql,jed (', ftoo o 6 C""""'"'" J. ") ( AU. vf.. c """eJ.&j c~d Tf?~x-t/r:- .>. e ~
5oct chi 10 ~ c.I'E}Jedbj e<k ( '' f'I1X> O!HZecav-hclj ( op® j ~ ~-' f J Eo F J'nave .-.e).-/: )
0

Te;,q {r l..e.J :

s-et <lhJ'lso
. c. J'€g1e •hi e J:- {_," s C.Yl p~~ . ?k .5_',1.S<Ie"l obje ctj {t -.-e~ bo I Jn../(reaJe TeA !J,'J-e} t.Jn'tcl;nidf'<Z<J T-fA/, bileA~d (,,
et'
I

c·kz!'f,x u::t = crC'aJt 0,~- Pet ( ''fxce~· -Ap pL;


(JQ
(1)
(c)l.r->1 ' ) ( v;0,·.~ If/CJc.rvhc)dij •fldc{e·r) Gyf:.zt!' r1 c))'v-e S~-ep;)/ t. (ij(j c I I)/- ,_L -
-...)
0
· _; // r-o•u: , c6/c:;r
hcoly' 5c~.to£1J~~ ~
0
>-+,
~

00
/A c../-,v£ &.Ju-f

F,i~"f"?,~;-;

~nT!"mrrr ,"'~"~,,~~=·""'"~""-""""T-~·--·~~n-lrr 1 ··r r 1 - 1 nm


~liveTech
fi<tlj Wlinfl sofuti,,.,

Actions
Actions
> Action is a set of one or more script statements to perfonn a specific .task (or) Set of meaningful
Statements.
> It is a module which contains set of Script statements for a specific functionality of an Application
and it is integrated with Local Repository and Local Datasheet.
> When we select new test in QTP, by default "Action 1" will be available on QTP Test Pane which is
visible, but internally one more Action is maintained by QTP called "Action 0" in which the
execution is started and ended [just iike void main() inC Language].
> We can insert maximum of255 Actions in one single Test.
Benefits of Actions
> It increases Readability i.e. instead of reading the total script, we can read Action by Action.
> Debugging is very easy, i.e. we can find logical errors in the Script.
> Makes code Reusable.
> Scripts are easy to maintain.
I
f
> Scripts are efficient.
> Saves Development time.
I
I Types of Actions
I Three types of actions
1. Non-reusable action
An action that can be used only in the test in which it was created, and only once.
2. Reusable action
An action that can be called multiple times by the test in which it was created (the local test) as well
as by other tests.
3. External action
A reusable action called in another test.
External actions are read-only in the calling test. They can be modified only in the test in which they
were created.

Creating New Actions


1. Go to Insert menu> Click on call to New Action and observe Insert call to New Action dialog box
2. Enter Action name and description and Select Reusable Action if you want to make the action
reusable.
3. Decide where to insert the action and select "At the end of the test" or "After the current step" and
Click [OK]

Inserting Actions
You can insert an Existing Action in 2 ways
1. Insert call to Copy of Action
2. Insert Call to Existing Action
-.,-
1. Insert call to Copy of Action
> Go to Insert menu and click on Copy of Action (or) right-click the action and select Insert [-------
Copy of Action and observe Select Action window. ~~

';;.- Select Test and Action name. t---


> Specify where to insert the action: At the end of the test (or) After the current step and Click
on (Ok].
> The actiop is inserted into the test as an independent, non-reusable action.

Mr.Venkat (Sr. Test Manager) Page 71 of 118


~liveTech
iktfy llslioR sditti.>aJ

2. Insert Call to Existing Action

Pre Requisite:
The Action that you need to insert should be a reusable action.

~ Go to Insert menu and click on 'Call to Existing Action


~ In the Select an action box, select the action you WMt to insert from the list
~ Specify where to insert the action: At the end or after the current step and click on [OK]
~ The action is inserted into the test as a call to the original action

Dividing the Test into Two Actions


~ Select the step
~ Go to Edit menu click on Action> Split Action, (or) right-click the step and choose Action> Split.
~ Choose one of the following options:
• Independent of each other. Splits the action into two sibling actions.
• Nested (the second action is called by the first). Splits the selected action into a parent action
whose last step calls the second, child action.

Operations done on actions


~ Rename Action: Edit > Action > Rename Action
~ Delete Action: Edit > Action > Delete Action
~ Edit Action Properties: Edit > Action properties

Action Template

1. Whenever we are using Framework, the Script Template fields must be used by the Test Engineer for
all Actions.
2. To save the Time without writing Template fields for every Action manually, QTP provides a feature
called "ACTION TEMPLATE".
3. If we define the Template fields in Action Template, here onwards, Template will be available by
default for every new action.
4. Navigation: ·
Open Notepad and Define the Template fields like below:
'Project Code
'Project Name
'Created By
'Date Created
'Test case' Name
'Test Case Objective
'Expected Result
'*********************************************************************************
5. Save the file as "ActiohTemplate.mst"(mst=module script template) in QTP -> "dat" folder.

Note:
1) ActionTemplate.mst is the standard name. tt--

2) Double Quotes are important then only the Template can be seen for every action in QTP TestPane.

'
~.-

Mr.Venkat (Sr. Test Manager) Page 72 of 118


~liveTech
t{y fit IWinB !of•ti<>D!

CHECK POINTS
Types of Check Points:
1. Standard Check Point
2. Bit Map Check Point
3. Database Check Point
4. Text Check Point
5. Text Area Check Point
6. Page Check Point (For Web Pages only)
7. Table Checkpoint (Web Table)
8. Image Check Point
9. XML Check Point
10. Accessibility Check Point

1) Standard Check Point


We can use this check point to verify the property of an object.
E x: v enry
·r u1pjda t e o r d er
Step Name Step description Expected result Actual Status
Step-1 Activate Window Disable
Step-2 Open Record Disable
Step-3 Perform change Enable

Navigation
Start Recording 0 Click on "Ok" 0 Activate Window (Flight 4a.exe) 0 File Menu 0
Click on Open Order 0 Select Order No. 0 Enter No. 0 Click on Ok [] Perform any
chang~q Click Update Orde.rO Stop RecordingO K~th~application (Flight4a.exe) in base
state 0 Identify positions in the Test Script to insert Check Points [After Activate window;
after open order; after perform change] 0 Stmi Recording 0 {Inse1i Menu 0 Check Points
0 Click on
Standard Check Point} {or F12} 0 show object []with 0 Click Ok 0 Enter Name of the
Check Point 0 Select Property with expected value (Enable-True= Enable; Enable-False=
Disable)O Click Ok 0 Stop Recording after insertion of all Check points at relevant places
0 Click Run DAnalyze results manually.

Ex:l
Window("Flight Reservation") .Activate
Window("Flight Reservation").WinButton("Update Order"). Check CheckPoint("CP _1 ")
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order. .. ''
~
Window("Flight Reservation'').WinButton("Update Order").Check CheckPoint("CP _2") r----
lr-
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set
[--
"ON" Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "30" I!
Window("Flight Reservation") .Dialog(" Open Order"). WinButton(" 0 K ").Click ,-:_-
11

Window("Flight Reservation").WinRadioButton("Economy").Set
Window("Flight Reservation").WinButton("Update Order").Check CheckPoint("CP_3")
Window("Flight Reservation").WinButton("Update Order"). Click ,
----
Mr. Venkat (Sr. Test Manager) Page 73 of 118 r-
c

i--------
.* liveTe.ch fil•efy ltstinn so{n!WaJ

wait (10)
If Window("Flight Reservation").ActiveX("Threed Panel Control").GetROProperty("text")
="Update Done ... " Then
msgbox ("Test is pass")
else
msgbox ("Test is fail")
End If

How to edit existing check point:


Place the cursor on Check Point which you want to edit 0 Right Click 0 Check Point
Properties 0 Select property 0 Change value or Rename Check
Point 0 Click Ok.
How to insert check point through Active Screen
Start Recording 0 Record Required Operation like as below [Click on "Ok" 0 Activate
Window (Flight 4a.exe) 0 File Menu 0 Click on Open Order D Select Order No. 0 Enter
No. 0 Click on Ok 0 Perform any change D Click Qpdate Order] 0 · Stop Recording 0
Keep the application (Flight4a.exe) in base state D Ide~y positions in the Test Script to
insert Check Points [After Activate window; after open or er; after perform change] D place
the cursor on specified statement 0 Click on Active Window D Right Click on object 0
Click on Insert Standard Check Point D Click Ok C Enter Check Point Name q Select
Property with expected value (Enable-True = Enable; Enable-False ~Disable) c: Select
option to insert statement (Before current Step I After cmTent Step) D Click Ok 0 Click Run
after insertion of all Che~k po~~~~ a~.Eeley~!!t p~~ces. 0 Analyze results manually.
----···----·-·-···------······--········-·--
fSac;.i)

~ . . . r:..,-- .

(l~~~~ ~--- _·· _·=1> ~,


1

-· t ·----~-~-- ·- . -··--------

2) Bit Map Check Point


We can use this Check Point to conduct test on Bitmaps.
Navigation ,
Start Recording 0 Help Menu 0 Click on about D Inscn Menu (QTP) · Check Point [l
Click Bit Map Check Point 0 Show Bitmap \Vith hand 1con {ti
4. Click Ok 0 Enter Na_me of the Check Point J Click on select area if you want to check a
specific area with in the Bit Map CJ Select save only selected area D Click on Ok 0 Stop
Recording 0 Close current application (Fiight4a)
5. Open another application (Flight 4b) 0 Click run to analyze results manually.
How to insert check point through Active Screen
Start Recording 0 Help Menu 0 Click on about D Click on Bit Map [ Stop
Recording D Click on Active Screen Icon Rjiit bck on Bit Map which you want to
check 0 Click on Insert Bitmap Check Point · Click Ok 0 Enter Name of the Check Point
0 Select area which area to be checked ,J Select option to insert statement (Before current

=----

Mr.Venkat (Sr. Test Manager) Page 74 of 118 L__
E -·--.-:-

~
Step I After Current Step) 0 Click on Ok 0 Cdse current application (Flight 4a) 0 Open
another application (Flight 4b) 0 Click run to analyze results manually.

3) Database Check Point


To automate backend testing we are using DatabaseCheck Point. During this testing we
are validating backend table in tetms of Data validation and data integrity.
Data validation means that the correctness of stming values into backend table.
Data integrity means that the impact of stored values on existing data table content. In
this we will be concentrate on primary keys, foreign keys, unique keys, ....... etc.,
To automate backend testing we can follow below approach .
....eo------
.~~~~~tl~-- •. ..~==-::~== i
4
~ q: '

,;;;r:· ·:-:·.~'.·'~. ·-~-·illlU==~ ___ j


~··· 'f"~t:;':"S;·,,;;;;oc<i''·=·~l
... '.·)
....
5
Actua
1 Data

Expected Value
==Fail
= ! Pass'

Step 1: Corinect to Database using DSN (Data Source Name)


Step 2:
Step 3:
Execute Specified Select statement.
Retrieve the result of SQL Statement
!
r -
-.-
Step 4: Perform any db Operation. '
"
E:------
Step 5: Compare expected data with actual data to verify the impact of ~
~
-.-
~
frontend operation on backend table content. ,';

~
Navigation .f

:----

:=--------
Mr.Venk:at (Sr. Test Manager) Page 75 of 118
C=
~----,--
Insert Menu 0 Check Point 0 Database Check Point 0 Select "Specify SQL Statement
Manually" 0 Next 0 Create 0 Machine Data source (Select Data source) 0 Select DSN
(QT_FLIGHT32) 0 Click Ok 0 SQL Statement (Enter your specified SQL Statement Ex:.
select * from orders) 0 Finish 0 Change the Check Point Name 0 Click Ok 0 Open
Frontend (perform any db operation like insert, delete, update) 0 Click Run 0 Analyze
results manually.

To Create New DSN


*) First of all you create One database in MS Access with specified table.

Navigation
Insert Menu 0 Check Point 0 Click on Database Check Point D Select "Specify SQL
Statement Manually" 0 Next 0 Create 0 Machine Data source (Select Data source) 0 New
0 Select type of data source (User
[Single user] I System Data Source
[multiple users]) 0 Next 0 Select a
Regular Expression.
Driver (Microsoft Access Driver) 0
[A-Z] [a-z] [0-9]*
Select database 0 Click Ok 0 Enter
Data Source Name with description 0 [A-Z] [a-z] [] [A-Z] [a-z]* [A-Z]
Click Ok 0 Click Ok D Take your [a-z]*
specified statement (Table) Ex:. select *
from orders) 0 Finish 0 Click Ok.

Note Database Check Point insertion is not possible through Active Screen.

4) Text Check Point


We can use this checkpoint to conduct test on text present on the object.
Navigation
Start Recording 0 Insert Menu J Check Point 0 Click on Text Check Point
1E Select object with hand icon C Clhk CJ Ok J Enter Name of the Check Point 0 Enter
your expected Text in 'Constant' [_i Select ~vfatching [(I) Match Case (2) Ignore Spaces (3)
Exact Match (4) Text Not displayed] [' Click on Ok
1E Stop Recording 0 Click run to analyze re3.1lts manually.
How to ins~rt check point through Active Screen
Start Recording 0 Activate WindoYv :- Stop Recording [ Click on Active
Screen Icon ight click on object which object text :,;ou want to check 0 Select insert
Text Check Point 0 Click Ok -:= Enter Checkpoint Name J Expected text fill in 'constant' 0
Select Matching [(1) Match Case (2) Ignore Spaces (3) Exact Match (4) Text Not displayed]
0 Select Insert Statement (Before I After Cunent step) ~j Click Ok 0 Click nm to analyze
results manually. 1!--
r-------
ci

5) Text Area Check Point t-


f
-r.-
g_
We can use this Checkpoint to conduct test on Text present in the specified screen area.

Navigation

r--- ---
Mr.Venkat (Sr. Test Manager) i
Page 76 of 118 ~UH~--

1
.*liveTech fit=dyltslin1Js,,fJJril'llj

Start Recording 0 Insert Menu 0 Check Point 0 Click on Text Area Check Point 0
Select the area specified to check 0 Click Ok 0 Enter Name of the Check Point 0
Enter your ~xpected Text in 'Constant' or
click on to~e Regular expression 0 Select type of Matching [(1) Match Case (2)
Ignore Spaces (3) Exact Match (4) Text Not displayed] q Click on O~q Stop
Recordingq Click run to analyze result.srnanually.
Note: Text Area Checkpoint is not possible through Active Screen.

6) Page Check Point (For Web Pages only)


We can use this Checkpoint to verify the properties of a web page.
Navigation
Start Recording 0 Insert Menu 0 Check Point 0 Select Standard Checkpoint
lE Show Image I Link with Hand Icon 0 Select Page 0 Click Ok 0 Enter Name of the
Checkpoint 0 Select Property [give your expe.cted value (Load time, No. of Images, No of
links)] 0 Click Ok 0 Stop Recording 0 Click Run ·
lE Analyze Results manually.

7) Table Checkpoint
We can use this checkpoint to verify the content of a Web Table.
Navigation
Start Recording 0 Insert Menu 0 Check pait 0 Select Standard Checkpoint q Select Image
with Hand Icopq Clicl<C! Select Web Tabl~q Click O!<C~ Enter name of the Checkpoint 0
Select Cell 0 Enter your expected data in constant 0 Ciick Ok 0 Stop Recording 0 Run 0
Analyze Results manually.

Note: L_
For Web Table
Browser("Browser Text Object Name").Page("Page Name").WebTable("Table
Ii
Name"). Check CheckPoint("Check Point Name") I
5
I
For Page Check Point ~"-,.-
P.
Browser("Browser Text Object Name").Page("·Page Name'').Check
CheckPoint("Check Point Name")

8) Image Check Point


To verify the properties of an Image, we can use Image
Check oint.·
Browser("Browser Text Object Narne").Page("Page Name").lrnage("Image
Name'').Check CheckPoint("Check Point Name")
av1ga Ion .or---

Start Recording 0 Insert Menu 0 Check point 0 Select Standard Checkpoint
lE Select Image with Hand Icon 0 Click 0 Click Ok U Enter name of the Checkpoint 0 :
Select Property (Alt) [give your expected value to that property] !!
!
lE Click Ok 0 Stop Recording 0 Run 0 Aalyze Results manually.

,-,-

Mr.Venk:at (Sr. Test Manager) Page 77 of 118


~liveTech
F
lin(; Its linn
sofntions

How can we check Tool Tips D Alt Property. r


9) XML Check Point

Navigation
To verify the content of an XML file we can use this check point.

Insert Menu D Check point D XML Check Point (From File) D Browse your XML File ph
Il----
D Click Ok D Enter name of the Checkpoint D Select Element Name D Specify your
expected valueD Click Ok D Run D Analyze Results manually. ·

10) Accessibility Check Point


We can use this checkpoint to verify whether the specified Web Page meets W3C
(WWWC) Standards or not (World Wide Web Consortium Standards)

Navigation
Tools Menu D Options. D Web Tab D Advanced D Select I Check in the check point
[ActiveX Check, Alt Property Check, Applet Check, Frame Titles Check, Multimedia Links
check, Server-side Image Check, Tables Check] D Ok D Ok D Start recording 0 Insert
Menu D Check Point 0 Click on Accessibility Check Point 0 Show Web Page with Hand
Icon 0 Click 0 Ok q Enter Name of the Checkpoi11tO Click Ol<O Stop
Recordingq Rupq Analyze Results manually.

Note
Page Checkpoint, Table Checkpoint, Image Checkpoint, Accessibility Checkpoint, XML
Checkpoint are applicable for Web Pages only.

it-----

Mr.Venkat (Sr. Test Manager) Page 78 of 118


~liveTech firtfj Its tin,q sofnticJIH

Recovery Scenario Manager (Folder 6)


~ To recover from unexpected events and errors that are occurred in the test envirorunent
during run session, we can use Recovery Scenario Manager.
~ For good recovery, error must be known the occurrence is unknown.
..... ?>:.

There are four types of events such as ~--


1. Application Crash
2. Popup Window
3. Test Run Error
4. Object State
1. Application Crash
An open application fails during Test Run.
Navigation
);> Resources Menu ->Recovery Scenario Manager
);> Click New Scenario-> Next ->Select "Application Crash" as Trigger event->Next
);> Select "selected executable application"->Next ->Next ->Select Recovery Operation
[Keyboard, Mouse Operation, Close Application Process, function Call, Restart,
Microsoft Windows]
);> Next ->Ifyou want to check Add another operation else uncheck->Next->Next->Enter
Scenario Name->Next->Finish ->Close
);> Save the scenario in specified location with '· .qrs"
);> qrs stands for "QuickTest Recovery Scenario".
Result:
Trigger Event:
Application crash /
Recovery Operations:
Restart Microsoft Windows
Post-Recovery Test Run Options:
Restart current test run
2. Popup Window
~ To handle unwanted POP UP's.
);> An open application fails during Test Run.
Navigation
);> .Resources Menu ->Recovery Scenario Manager ->Click New Scenario-> Next ->Select
"Popup Window" as Trigger event->Next
);> Cljck on Hand Icon->ShO\v unwanted window with Hand icon ->Next ->Select function
call as Recovery Operation ->Next [Open Notepad ->Sc:ve empty file with .vbs
extension] ·
~ Browse the .vbs fie path ->Next ->Uncheck Add another Recovery Operation ->Next->
Select Post-Recovery Test Run Option [Repeat current step and continue] ->Next ->Enter
Scenario Name ->Next ->Finish
);> Save the scenario in specified location with ".qrs"
~ Record required Recovery Operation (Click [OK] , Click [Cancel] on POP UP) take the
script into function
);> Save the library file ->Click Run

f-=----=--=----=
Mr.Venkat (Sr. Test Manager) Page 79 of 118 ~
t--
~
I,
~liveTech
firefy wlinn solittiou

3. Test Run Error


A step in your test does not run successfully then Test Run Error can be raised.
Navigation
~ Select Next 0 New 0 Recovery Scenario Manager 0 Resources Menu 0 select any
error Next 0 "Testrunerror Window'; as Trigger event 0 o Next Select function call as
Recovery Operation 0 Next 0 Next 0 D 0 Browse the Save empty file with .vbs
extension] 0 [Open Notepad 0 Next Uncheck Add another Recovery Operation 0 Next
0 .vbs fie path 0
~ Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run,
Stop the Test Run] Select Option DFinish Next [J Enter Scenario Name 0 Next 0 0
~ Record required Recovery Operation Save the scenario with ".qrs" 0 [Click ok, Click
Cancel] take the script into function
? Click Run Save the library file 0
4. Object State
The property values of an object in your application match specified values. You can specify
, property values for each object in the hierarchy.
Navigation
>- Resources Menu 0 Recovery Scenario Manager D New 0 Next 0 Select "Object state
\Vindow" as Trigger event 0 Next 0 Click on Hand Icon 0 Show object with hand icon
0 Next 0 Next->select object property with value (enabled ,false)->click next 0 Select
function call as Recovery Operation [] Next [Open Notepad 0 Save empty file with .vbs
extension] fJ Browse the .vbs fie path c:: Next 0 Uncheck Add another Recovery
Operation D Next 0
;;;, Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run,
Stop the Test Run] 0 Next [j Enter Scenario Name 0 Next 0 Select Option DFinish
> Save the scenario with ··.qrs" ~~ Record required Recovery Operation [Click ok, Click
Cancel] take the script into function
;- Save the library file iJ Click Run
Output Values
~ It is a step in which one or more values are captured at a specific point in the test.
> En3blcs to choose which property values to output
Types of Output Values
111
Standard Output values
a Text Output values
• Text area outpur value
• Database ·output value
• XML output value
While Recording
Choose Insert> Output Value. (Or) Insert Output Value button on the toolbar
\Vhile editing your test
Right-click on the object in the Active Screen and choose Insert Output Value. (or) right-click
the step and choose Insert Output Value.

~-----

Mr.Venkat (Sr. Test Manager) Page 80 of 118


·.'·'r
,.

if·!
I ---
Regular Expressions
• Whenever the object text is changing dynamically at run time, we can use regular
expresswns.
• If property value is changing during each run session, use regular expressions when defining
or parameterizing property values
• In standard checkpoint the expected value of an object's property can be set as a regular
expression so that an object with a varying value can be verified
Example: When creating a standard checkpoint to verify the property values of an object, you
can set the expected value of an object's property as a regular expression so that an object with a
varying value can be verified

Regular Expressions Pattern

Backslash Character ( \ )
Match any Single Character ( . )
Match any Single Character in a List ( [.xy] )
Match any Single Character Not in a List ( ["xy] )
Match any Single Character within a Range ( [x-y] )
Match Zero or More Specific Characters ( * )
Match One or More Specific Characters ( + )
Match Zero or One Specific Character ( ? )
Grouping Regular Expressions ( ( ) )
Match One of Several Regular Expressions ( I )
Match the Beginning of a Line ( " )
Match the End of a Line ( $ )
Match Any AlphaNumeric Character Including the Underscore ( \w)
Match Any Non-AlphaNumeric Character ( \W)
Combining Regular Expression Operators
Virtual Objects
>- Virtual objects enables to record and run tests on objects that are not normally recognized by
Quick Test.
>- QTP'is failed to recognized application object, Go for Virtual Object.

Using the Virtual Object Wizard


• Mapa virtual object to a standard object class such as a button or a check box.
• Specify the boundaries & the parent of the virtual object
• Assign it a name.

You can group your virtual objects logically by assigning them to collections.

Mr.Venkat (Sr. Test Manager) Page 81 of 118


~
f--
At liveTech liulj ttslilg scr.IW.,

Test Batch Runner


>- In my current project we used two methods to execute the Scripts.
1. Batch Processing
2. Using Framework - AOM
1. Batch Processing ~--
Purpose of Batch Mode in QTP:
• In order to run test cases/test scripts which have same related functionality as a group
• In order to reduce the regression testing effort as we test specific group of test scripts
which have same related functionality when a single test case in that particular group
fails, Instead of going for regression on all the test cases which are available
• In order to run many tests at a time as a group we use Batch mode.
Pre requisites:
Before going for batch processing we have
To follow the below steps:
>- Go to Tools menu --> Options-7 Select Run tab-7 Select Allow other HP Products to run
tests and components and Click on [OK]
Steps to work with Batch runner:
> Start-7 Programs-7 QTP-7 Tools-7 Click on Test Batch Runner and Observe Test Batch
Runner window
>- Go to Batch menu and click on ADD-7 Browse and select the related Test Scripts which
need to run in Test Batch Mode
Saving the Batch scripts:
,_ We have to save the scripts which were added into the batch mode with proper Naming
conventions and ".MTB" (modular Test Batch) extension.
This is the way we create various Batches for regression testing.
Running the Test scripts in Batch mode:
> Go to Batch menu-7 Click on RUN
r Check the behavior of your application
> Observe Test Results Summary window
> If any Failures or Warnings, Report it as a Defect using Quality Center 10.0 I Bugzilla
Automation Object Model (Folder 7)
To pre-configure QTP Test settings, we can use Automation Object Model
Open Notepad prepare the script like as below and save the file with *. vbs extension

Set q tp=Createobject(" QuickTest.application ")


qtp.launch
qtp. visible=True
qtp.Showpanescreen "DataTable" ,False
qtp.Showpanescreen "DebugViewer" ,True
qtp.Showpanescreen "ActiveScreen" ,True
qtp.open "E:\Linear\Test_Login"
qtp.test.run
qtp.open "E:\Linear\Test_Update"
qtp.test.run
qtp.quit

~---=----

1 Mr.Venkat (Sr. Test Manager) Page 82 of 118


,_:_
L
] ~
QuickTest Script Editor
> The QuickTest Script Editor is a tool that enables you to open and edit multiple test scripts
and function libraries simultaneously.
>- You can also create new function libraries.
> You can modify the script of a test, but you cannot create new tests, associate or remove ~--
associated function libraries, or change information such as existing test names, test settings,
parameterization, or Data Table values.

Navigation:
Start> Programs >QuickTestProfessional > Tools> QuickTest Script Editor.

, L .. ~. Reb.Jrnt·brnc
El .Jli] l.olercur~·T outs
· : ....~ Sgn_in [Ac.tionA]
i · -~ copy of Fltgt"I:O'der
?7t-rr.--.~""' er('\Nelcom(l: IAorcury Tours
! !... ~ RebJrroH::>rne [Action:,)
"'"''•-:r.-·•. M"er('\IYelo::nne: MercuryTours
B ft"ID Rc;;~Exp·cs~i:m
v.,ut->rr""'"' er('\Nel corn e: l,,j e rcury· Tours
: · ' " A::tbnl u?&4--io·.-""''"' erf'Viel o:• me: 1-,1 e rcur.t Tout's
..c~-a,n.;. ,r::: er(''v'/elo::•me: f.Aercu~.·· Tours
,•z;.<:t-;rrr.vr: cr('Vv'olcomo: 1-Aorclny Tours
· er('\l'leloorne: t..~1ercuryTours
Display area -.;;r----------- er('V"iel DJ rn e: fv"1 e rcur.:/ Tour:;
5 er('Vi el con·, e: l·r1 e rcur::/ Tours
Resources er('VieloJme: t·r1ercury··rours
pane
Flow pane

The QuickTest Script Editor window contains the following key elements:

Flow Pane:
~ Displays the flow of the action calls for each ofthe open tests.
Resources Pane:
~ Displays the open tests, its local actions and any function libraries associated with each
;,
test, as well as a list of all currently open function libraries. ~.-

Display area:
~ Displays a window for each of the open tests and function libraries. -
.r----

~---
Mr.Venkat (Sr. Test Mnnager) Page 83 of 118
r-
~
Step Generator (F7)

~ It is used to generate steps in the Test pane without click on start Recording.
~ Step Generator consists of statements in three categories such as
1. Functions (Built-In,Library ... ) I--
2. Utility objects (Systemutil, Datatable ... )
3. Test Objects (Test Operations like Set, Click, GetROProperty ... )
1. Functions
~ This category specifies all general and mathematical operations such as left, right, len, time,
cint, cdbl, cstr, ltrim, rtrim, trim etc.,
2. Test Object
~ This category specifies the operations which are performed on the objects such as Set,
Select, Activate, SetSecure, Click, GetVisibleText, GetROProperty, GetTOProperty,
Getltem, GetltemCount, GetContent .... Etc.,
3. Utility Objects
~ This category specifies all miscellaneous operations such as DataTable Operations,
SystemUtil Operations, QCUtil Operations, Recovery Operations etc.,

._~~

lvlr.Vcnkat (Sr. Test Manager) Page 84 of 1 IS


!l' i

~liveTech
fiNly Wlinfl scfulions

Automation Framework
~ Automation Frame work is nothing but an Automation planning for the project which is
prepared by Test Lead.
~ It helps to control the automation .project in a better way.
~ In my current project, we are using "Hybrid framework" which is prepared by my Test
Lead (But, we customized the framework as per our project needs).

Automation Frame work contains:


~ What functionalities to be automated
~ What Approach to be followed
~ What levels we have to use in order to develop the scripts (either it is Record I Actions I
VB script I Functions I Descriptive Programming I Step Generator I Drag and Drop)
);> What naming conventions to be followed
~ Where to store the scripts
);> Calling the scripts
~ Directory structure Qf automation
);> Where to store the Test results
-:-:> sd~ re_
_;../ ~ 6t.tr C..QJ.
Types of FrameworK
1. Linear Framework
2. Modular Framework
3. Data Driven Framework
4. Keyword-Driven Framework
5. · Hybrid Framework

1. Linear Framework
> Without using any functions, reusable Actions, we are going to write the script called
Linear Framework
> There is no Reusability.
> In this Framework we are preparing script for scenarios using Record and Playback
method
Navigation:
;;- Record required operation 0 Enhance Test Script as per Scenario 0 Save test 0 take the
help of Test Batch Runner Tool to execute group of tests sequentially

2. Modular Frame,vork
> Going to write scripts module wise
> Every operation we have to cover in our script by using reusable actions or functions
);;> We should maintain function calls for navigating the whole test case
> In this framework we are preparing script for scenarios using Reusable components I .--
Reusable Actions. "
,-.- -

> When client asks we don't want all script, we need only function calls, then we go for ~

Modular Framework
> Code hiding is there, by calling all scripts in one script, we are hiding code

I Mr.Venkat (Sr. Test Manager) Page 85 of 118 t


a-'-
~
Navigation:
Record required repeatable operations 0 Save them in a specific location as reusable action 0
Prepare script for scenarios using those reusable actions 0 Save them 0 Take the help of Test
Batch Runner Tool to execute group of tests sequentially.

3. Data -Driven Framework


J-
> Data is running or Driving the whole test cases is called Data Driven Framework
> If 80% of the scripts have test data to automate, we go for Data Driven Framework
> We have to store all "test data" in one folder and retrieve the "Test data" whenever we
need in script

4. Key-Word driven Framework


> In this framework we are preparing script for scenario using functions and driven, the
script with keywords.
5. Hybrid Framework
> Combination of all above called Hybrid Framework
In my current project Automation Testing Process started with three Stages
2. Tool Evaluation - Stage 1

7. Analyzing the Test cases


8. Preparing Analysis sheet
9. Estimating script development time -Stage 2
10. Sending summary sheet for Approval .
11. Confirmation

16.
_.
Automation Folder ~~ructure Preparing
r1
~r---

17. Preparing Object Repository · · ~


~
18. Creating re-usable components and functions
19. Creating scripts and Enhancing scripts f
!~

20. Dry run -Stage 3 ·~.,


"
b_;_
21. Final Execution r,-

22. Peer Execution


23. Delivery of scripts
24. Enhancements

1. Tool Evaluation
> In first stage we evaluated commercial and open source test automation tools (QTP and
Selenium)
> After initial evaluation with our project 25 features, we finalized QTP
2. Analyzing the Test cases .
> In Second stage, we analyzed arid understanding project test cases
> Getting Knowledge Transfer from manual Test Engineers

;;---
Mr.Venkat (Sr. Test Manager) Page 86 of 118
I
3. Preparing analysis sheet
.)> After analyzing the test cases prepared analysis report for test cases to be automated and
not to be automated
4. Estimating script development time
.)> Estimating script development time
5. Sending summary sheet for approval
~ Sending automation test case summary sheet for approval
6. Confirmation
~ Approval from Client or Manager

Key-word Driven Framework Implementation


In my current project we followed Key-word driven framework follows ... I
' '

1. Ickatified three scenarios for automation


1. Login into application
2. Insert Order
3. Update Order
2. Folder Structure Preparation

I
~

3. Four functions are developed


1. Login
2. lnsert order

II
l
3. Update_order
4. Close_App
'*************************** Login Function ***********************************
'Function Name :Login
I
'Function Description : It is used to login application -':_I
'Parameters : strUrl, strUid, strPwd
'Date Created : 23-Mar-2012
'Created by : Venkat
'****************************************************************************
Function Login(Byval strUrl,Byval strUid, Byval strPwd)

Mr.Venkat (Sr. Test Manager) Page 87 of 118


f---
-*liveTech
E
fkefy tiiiisflliii•IW.,
L
f ..

Systemutil.Run strUrl
Dialog("Login ").Activate
Dialog("Login").WinEdit("Agent Name:").Set strUid
Dialog("Login").WinEdit("Password:").Set strPwd
Dialog("Login").WinButton("OK").Click
l---
IfWindow("Flight Reservation").Exist Then
Reporter.ReportEvent micPass,"Login","Login Successfull"
Login="Pass"
Else
Reporter.ReportEvent micFail,"Login","Login Unsuccessfull"
Login="Fail"
End if

End Function

'****************************Insert Order*************************************
'Function Name :Insert Order
'Function Description : It is used to verify Order
'Parameters : dtDate,strFly_From,strFly_To,intTof, strName, intTic
'Date Created : 23-Mar-2012 I

F
'Created by : Venkat
'*****************************************************************************
Function Insert_Order(Byval dtDate,Byval strFly_From,Byval strFly_To,Byval intTof,Byval ~

strName,Byval intTic) 8..__._ ..

Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"


Window("Flight Reservation'').WinObject("Date of Flight:"). Type dtDate I;
Window("Flight Reservation").WinComboBox("Fly From: ").Select strFly_From ~
Window("Flight Reservation").WinComboBox("Fly To:").Select strFly_To ~

Window("Flight Reservation").WinButton("FLIGHT").Click ! i·•


~
~:~-
Window("Flight Reservation").Dialog("Flights Table"). WinList("From").Select intTof ,.

Window("Flight Reservation").Dialog("Flights Table").\VinButton("OK").Click II


Window("Flight Reservation'').WinEdit("Name: ").Set strName I
I
Window(" Flight Reservation"). WinEdit("Tickets: ").Set intTic '
Window("Flight Reservation").WinButton("Insert Order").Click 1
wait(IO) I

I
strMsg = Window("Flight" Reservation"). WinObject("Insert Done").GetROProperty("text")

If strMsg="Insert Done... " Then


~

Reporter.ReportEvent micPass,"InsertOrder","Insert Order Done Successfully" ;;---

Insert Order="Pass"
Else
Reporter.ReportEvent micFail,"InsertOrder","Insert Order Failed"
Insert Order="Fail"

Mr. Venkat (Sr. Test Manager) Page 88 of 118


.* liveTechfiNly ltJiiniJ JOf#Mnl

End If
End Function
'**************************** Update_Order ***********************************
'Function N arne : Update_Order ·
'Function Description : It is used to very Update Order
'Parameters : intOrder,strName
'Date Created : 23-Mar-2012
'Created by : Venkat
'****************************************************************************
Function Update_Order(Byval intOrder,Byval strName)

I Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order... "


Window(" Flight Reservation ").Dialog("Open Order"). WinCheckBox("Order No. ").Set ON

I Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set intOrder


Window("Flight Reservation ").Dialog("Open Order"). WinButton("OK"). Click

I
Window("Flight Reservation"). WinEditC'Name:").Set strName
Window("Flight Reservation"). WinButton("Update Order"). Click
strMsg = Window("Flight Reservation").WinObject("Undate Order").GetROProperty("text")
If strMsg="Update Done... " Then

I
Reporter.ReportEvent micPass,"Update Order","Update done successfully"
Update_Order="Pass"
Else
Reporter.ReportEvent micFail,"Update Order","Update Failed"

l
I
j
End If
Update_Order="Fail"

End Function
'**************************Close_App*****************************************
'Function Name : Close_App
'Function Description : It is used to Close the application
'Parameters :- NA-
'Date Created : 23-Mar-2012
'Created by : Venkat
'*****************************************************************************
Function Close_App()
Window("Flight Reservation").Close
If not Window("Flight Reservation ").Exist(l 0) Then
Reporter.ReportEvent micPass, "Close app", "Application closed
successfully" ~.
Close~App="Pass" f.
Else tr
Reporter.ReportEvent micFail,"Close app","Application not closed" J'
!:!.________
Close_App="Fail"
End If I ~r
~
l

:-:-
End Function \ .~-
' IT
'***************************************************************************** ~
4. Library

Mr.Venkat (Sr. Test Manager) Page 89 of 118



.~
!
);> All four functions copy into Notepad and Save it as .vbs extension
);> Copy the functions file into "Library" folder
5. Object Repository
);> Object Repository creation for application
);> Go to Resources~ Object Repository~ Add Objects to Local
);> Export these repository into "Object Repository" folder
t ---
6. Environment
);> Environmental variable creation
);> File~ Settings~ Environment~ User defined~ Add~ Enter Name as uri~
Enter Value as "uri of application"~ [OK]
);> Export user-defined environment variables to an XML file into "Environment"
folder
7. Recovery Scenario
);> Resources ~ Recovery Scenario Manager~ New Scenario icon ~Next ~
Select event
);> Save recovery Scenarios into "Recovery Scenario" folder
8. Test Data
);> Create input.xls file and save it into "Test Data" folder
);> Create three worksheets
1. Module
2. Test Cases
3. Test Steps
1. Module
I

Moduleld IModuleNarne ModuleExe ;


M1 !Admin Y ·-l
~----------+-------------~------------·-1
M2 !Customer N ......_____________.
L--.-.-----------'-------------'----·-··'"·
2. Test Cases

3. Test Steps:

·J~~-t?.?. _jgJq?.~_APP . . . . !ca


tc03 ts1 ilogin lin
~~q~=~?.l..J!-:lP99!~_Qr9~r :uo
tc03 ts3 !Close App iCa

Mr.Venk:at (Sr. Test Manager) Page 90 of118


I ~liveTech

I
I
filot/jltstillJisdltWiu

9. Test Script
10. Write Driver script
11. All files need to associate with script
· )> Library File ~Settings ~Resources ~Add
)> Environment Variable File ~Settings~ Environment ~User Defined~ Load
)> Recovery Scenario File ~Settings ~Recovery ~Add
)> Repository Resources ~Associate Repository ~Add
Driver Script
*****************************************************************************
1
Project Code : LT- 333
1
Project Name : Flight Application
1
Created By : Venkat
1
Date Created : 24-Jan-2011
1
Test case Name : Flight Application Home page
1
Test case Objective : Verify Login, Insert Order and Update Order
1
Expected Result : Ordets should be Inserted and updated successfully
'**********************************Variable Declaration*************************
Option Explicit . :\
Dim Mcount, Mexe, Moduleid, Moduleid1, Tcount, res, Keyword, Tscount Tcid, Tcid1, i,j, k . ·~

**********************Functional Scenario**************************************
'Adding sheet to runtime Data Table
Datatable.AddSheet ("Module")
Datatable.AddSheet("Testcase")
Datatable.AddSheet C1Teststep")
'Importing Sheets from an External Excel File
Datatable.ImportSheet "C:\Flightresrvation\Testdata\Input. xis", 1, "Module"
Datatable.lmportSheet "C :\Flightresrvati on\Testdata\Input.xls" ,2, "Testcase"
Datatable.ImportSheet "C:\Flightresrvation\Testdata\lnput.xls",~,"Teststep"
Mcount=DataTable.GetSheet("Module").GetRowCount
For i= 1 to Mcount step 1
Datatable.SetCurrentRow(i)
Mexe=Datatable.Va!u~{3,"Module") ~~,(,~, s,he.Q.:h-Jc~)
Ifucase(Mexe)="Y" Then
Moduleid=Datatable. Value(1, "Module")
Tcount=Datatable. GetSheet("Testcases"). GetRowCount
For j=l to Tcount step 1
Datatable.SetCurrentRow (j)- .
I T~=DataTable.Value(3,"Testcases 11 )
I Moduleid1 =DataTable.Value(4, "Testcases") i'
I"
IfModuleidl= Moduleid and ucase(T~="Y" Then
I
I
Tcid=Datatable.Value(1,"Testcases 11 )
Tscount=Datatable. GetSheet("Teststeps "). GetRowCount
r'
~.
B -,-
~! ~
~
I For k=l to Tscount step 1
Datatable.SetCurrentRmy(k)
Tcidl =Datatable.Value(5,"Teststeps")
IfTcid1=Tcid Then

Mr.Venkat (Sr. Test Manager) Page 91 of 118


r--
Keyword=Datatable.Value(3,"Teststeps")
Select Case Keyword
Case "In"
res= Login( environment. Value("url "), "venkat", "mercury")
Datatable.Value(4, "Teststeps")=res
Case "ca" I-
res=Close app()
Datatable.Value(4,"Teststeps")=res
Case "ins"
res=insert_order("090911 ","Denver","London",l,"John Gun","2")
Datatable. Value(4, "Teststeps")=res
Case "uo"
res=Update_Order("2","John Nithu")
Datatable. Value(4, "Teststeps")=res
End Select
End If
Next
End If
Next
End If
Next
'Export Results to 'TestLog' folder
Datatable.ExportSheet "C :\Flightresrvation\TestLog\Result.xls", "T eststeps"

10. Test Run


~ Create AOM.vbs and Save into "TestRun" folder.
Set qtp=CreateObject("Quicktest.Application")
qtp.Launch
qtp. visible=True
qtp.open "C:\Flightresrvation\Testscripts\Driverscript"
qtp.test.run
qtp.quit
11. Execution:
~ Go to Test Data Folder, In "input.xls" sheet mark to "Y" (yes) of the Module, Test cases
which are need to execute in current build
~ Go to Test Run Folder and click on AOM.vbs file
~ Observe-Test log Folder for results

"~·
.................._.....,_ ___ ,.,~

Teststeps 1Function Name K~ord :Result 'Testcaseld ;


'
tcOl ts1 iLogin In 'Pass 'tc01 i
tc01 ts2 !Close App !Pass :tc01 I
ca I
tc02 ts1 !Login In Pass tc02
tc02 ts2 !Insert Oder ins 'Pass tc02 t
tc2 ts3 !Close App lea !Pass tc02 i
I
tc03 ts1 iLoqin In :Pass tc03 i

tc03 ts2 \Update Order uo .Pass tc03


tc03 ts3 \Close App ca. •Pass tc03 ---

:_____ ____

:-
Mr.Venkat (Sr. Test Manager) Page 92 of 118 ~ - --

~
Data Driven Framework Implementation
1. Folder Structure Preparation

5I fl ,~tpi~~;
10 Environment
IQ library
~Recovery

I ~::;, Repository
Q Test Data
fO'Test Log,'
e.;, Test Run
ra;a Tes~'Scrfpt:
2. Object Repository
~ Object Repository creation for application
~, Go to Resources -7 Object Repository -7 Add Objects to Local
~ Export these repository into "Object Repository" folder
3. Environment
~ Environmental variable creation
~ File -7 Settings -7 Environment -7 User defined -7 Add -7 Enter Name as uri -7
Enter Value as "url of application" ,-7 [OK]
~ Export user-defined environment variables to an XML file into "Environment"
folder
4. Recovery Scenario
~ Resources -7 Recovery Scenario Manager -7 New Scenario tcon -7 Next -7
Select event
~ , Save recovery Scenarios into "Recovery Scenario" folder
5. Test Data
> Create input.xls file and save it into "Test Data" folder
6. Test Script
~ Write Driver script
· ~ All files need to associate with script
1. Environment :File-7 Settings-7 Environment-7 User Defined -7 Load
2. Recovery Scenario: File -7Settings -7 Recovery -7 Add
3. Repository: Resources -7 Associate Repository -7 Add
*****************************************************************************
1
Project Code : LT 333
1
Project Name : Flight Application
1
Created By : Venkat
1
Date Created : 23-Mar-2012 ~----

1
Test case Name :Flight Application 11

1
Test case Objective: Verify Calculation Test ,-,-

1
Expected Result : Calculation must be happen as per FRS
I*****************************************************************************

Mr.Venkat (Sr. Test Manager) Page 93 of 118


[
~
l==
_I_

Option explicit j
Dim Row_Count,i,Order_ Number,Tic,Price,Prc, Total, Tot f
DataTable.AddSheet ("Input") J
DataTable.AddSheet("Output")
DataTable.GetSheet("Output").AddParameter "Tickts","" I
DataTable.GetSheet("Output").AddParameter "Price",""
DataTable.GetSheet("Output").AddParameter "Total",""
DataTable.GetSheet("Output").AddParameter "Results",""
DataTable.ImportSheet "D:\\Testdata.xls",l, "Input"
Row_ Count=Datatable.GetSheet("Input").GetRowCount
For i=l to Row_Count step 1
Datatable.SetCurrentRow(i)
Order_Number=Datatable. Value("Ordemumber", "Input")
Window("Flight Reservation").Activate
Window("Flight Reservation"). WinMenu("Menu").Select "File; Open Order... "
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order"). WinEdit("Edit").Set Order_Number
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Tic= Window("Flight Reservation").WinEdit("Tickets:").GetVisibleText()
Price= Window("Flight Reservation").WinEdit("Price:").GetVisibleText()
Prc=mid(Price,2,len(Price)-1)
Total= Window("Flight Reservation").WinEdit("Total:").GetVisibleText()
Tot=mid(Total,2,1en(Total)-1)
If cdbl(Tot)=cdbl(Prc)*cdbl{Tic) Then
Reporter.ReportEvent micPass,"Calculation Test","Test is Pass"
Datatable. Value("Tickts", "Output")=Tic
Datatable.Value("Price", "Output")=Prc
Datatable.Value("Total ", "Output")=Tot
Datatable.Value("Results","Output")="Test is Pass"
Else
Reporter.ReportEvent micFail,"Calculation Test'',"Test is Fail"
Datatable. Value("Tickts", "Output")=Tic
Datatable.Value("Price", "Output")=Prc
Datatable.Value("Total","Output")=Tot
Datatable.Value("Results","Output")="Test is Fail"
End If
Next
Datatable.ExportSheet "D:\OutputSheet.xls","Output"
*****************************************************************************
7. Test Run
)> Create AOM.vbs and Save into "TestLog" folder.
8. Execution: lt------
)> Go to Test Data Folder, In "input.xls" sheet mark to "Y" (yes) of the Module, Test cases ·-'-
which are need to execute in current build
- )> Go to Test Run Folder and click on AOM.vbs file
)> Observe Test log Folder for results

~---


Mr.Venkat (Sr. Test Manager) Page 94 of 118 L_ __ _
~

'~
Web Programming I HP QC I Interview Questions
Script 1:
How to close Pop ups during Run time
a=lO
b=20
Set ObjShell=CreateObject("wscript.shell")
If b=a+ 10 Then ·
objShell.popup "b is equal to a", 2 (Time in Seconds)
else
objShell.popup "b is not equal to a", 5
End If

Script 2:
How to delete cookies
Systemutil.Run "iexplore", "www.google.com"
wait(5)
webutil.DeleteCookies
systemutil.CloseDescendentProcesses

Script 3:
I How to close all the browsers
Set objDesc=Description. Create
objDesc.Add "micclass","Browser"

set objColl=Desktop.ChildObjects(objDesc)

1-
,r
msgbox objColl.count
For i=O to objColl.count-1 step 1
BrN ame=objColl( i). GetropropertyC'name")
Msgbox BrName
objColl(i).close "
~
tf-----
c!
Next ~7

Script 4:
'How to close all t.b.e browsers except our specified browser
Option explicit
Dim objDesc,objColl,BrName,i
Set objDesc=Description.Create
objDesc.Add "micclass ","Browser"
Set objColl=::::Desktop.ChildObjects(objDesc)
For i=O to objColl.count-1 step 1
BrN ame=objColl(i). GetRoProperty("name")
IfBrName="Google" Then
'Dont do anything
Else

f7
Mr.Venkat (Sr. Test Manager) Page 95 of 1 1
objColl(i).close
End If
Next
Script 5:
How to close all items in Desktop except QTP

Set objDesc =Description. Create


objDesc("micClass").Value ="Browser"

Set objBrs = Desktop.ChildObjects(objDesc)

Fori = 0 to objBrs.count-1
strBrName=objBrs(i).GetROProp~rty("name")
If strBrName <> "QUICK TEST PROFESSIONAl}' Then
objBrs(i).close
End If
Next

Script 6:
How to count number of links in a specified web page
Set oDesc=Description.Create
oDesc.Add "micclass", "Link"

Set objColl=Browser("title:=Google").Page("title:=Google").ChildObjects(oDesc)

For i=O to objColl.Count-1 step 1


LinkName=objColl(i).GetRoProperty("name")
Print LinkName
Next

Script 7:
'How to count no of links in a specified web page and how to display their names one by
one into notepad
Option explicit
Dim objDes,opjColl,objFso,objf,i,link_name
Set objDes =description.Create
objDes.Add "micclass","Link"
Set objFso=createobject("scripting.tilesystemobject")
s.et objf=objFso.CreateTextFile("D:\linknames.txt")
. set objColl=Browser("title:=. *").Page("title:=. *").ChildObjects(objDes)
For i=O to objColl.count-1 step 1
link_name=objColl(i).getroproperty("name") c
o--
[
objf.WriteLine link name "-----
Next
objf.Close
Set objFso=nothing

t-~----

Mr.Venkat (Sr. Test Manager)


Page 96 of 118 r-
~:-
~
!
rt
I
j
Script 8:
How to Set link names one by on into Excel
Option explicit
Dim objExcel,objSheet,objWbook,objCell,i,Link_Name,objColl,objDesc
C

Set objExcel=CreateObject("Excel.application")
objExcel. Visible=True
objExcel. W orkbooks.Add
Set objSheet=objExcel.ActiveSheet
1
objSheet.cells(l, l)="LinkNames"
Set objCell=objSheet.cells( 1,1)
objCell.Font.color=Vbblue
Set objDesc=Descrip.tion.Create
objDesc.Add "micclass", "Link"
Set objColl=Browser("title:=. *").page("title:=. * '').ChildObjects(objDesc)
For i=O to objColl.count-1 step 1

Link_Name=Browser("title:=. * ").page("title:=. * ") .link("index :=" &i) .getroprop~S:rty("name")


objSheet.cells(i+2,l)=Link Name

Next
Set objWbook=objExcel.ActiveWorkbook
objWbook.SaveAs "F:\Results.xls"
objExcel. Quit
Set objExcel=Nothing

Script 9:
How do we validate links in web page and how to display link names with status in excel

Set objExcel=Createobject("excel.application")
objExcel.Visible=True
objExcel. Workbooks.Add
set objSheet=objExcel.ActiveSheet
objSheet.Cells(1,l)="LinkName"
objSheet.Cells(1,2)="Expected URL"
objSheet.Cells(1,3)="Actual URL"
objSheet.Cells(1,4)="Status"

Set objDesc=Description.Create
objDesc("micclass "). value="Link"
set objLinks=Browser("title:=. *").page("title:=. *").childobjects( objDesc)
msgbox objLinks.count
,-,-
2------

For i=O to objLinks.count-1 step 1


strLinkName= Browser("title:=. *").page("ti tie:=. *").L i nk("name:=. *","index :="&i}.Getroproperty("name")
strExpUrl=Browser("title:=. *").page("title:=. *").Link(" name:~.*" ,"in~ex :=" &i).GetRoproperty("url")

Browser("title:=. *").page("title:=. *").Link(" name:=.*", "index:=" &i).click

Mr.Venkat (Sr. Test Manager) Page 97 of 118


\1
~
j
~liveTech

II
s..ry ttslilfl sof>tW.J

Browser("title:=. *").Sync
strActUrl=Browser("title:=. *").GetROProperty("url")
If instr(l ,strActUrl,strExpUrl,l )>OThen
Reporter.ReportEvent micPass, "Link Vaidation ","Succeed"
objSheet.Cells(i+2,l)=strLinkName
objSheet.Cells(i+2,2)=strExpUrl
objSheet.Cells(i+2,3)=strActUrl
I t----
obj Sheet. Cells(i+2,4 )="Pass"
Set C4=objSheet.Cells(i+2,4)
C4.Font.color=vbGreen
I
Else
Reporter.ReportEvent micFail,"Link Vaidation","Failed"
objSheet.Cells(i+2, I )=strLinkName
objSheet.Cells(i+2,2)=strExpUrl
objSheet.Cells(i+2,3)=strActUrl
objSheet.Cells(i+2,4)="Fail"
Set C4=objSheet.Cells(i+2,4)
C4.Font.color=vbRed
End If
Browser("title:=. *").Back

II
Next
set objWbook=obj Ex eel. ActiveWorkbook
objWbook.SaveAs "C:\OutPutdata.xls"

objExcel.Quit

Set objExcel=nothing

r--
,,
_,,-

~---

Mr.Venkat (Sr. Test Manager) Page 98 of 118 r-


-'-
~
tl
HP Quality Center
THREE WAYS TO REPORT DEFECTS USING QUALITY CENTER:
1. Using Test Results window, Go to Tools and Click on 'Add Defect'
2. QTP submit defect for each failed step- QTP is connected to QC we have to Select option (Go to toolsL1
OptionsO RunO Select the "Submit a defect to Quality Center for each failed step")
3. Login into Quality Center and report the defect

INTRODUCTION:
Quality Center is a Test Management tool from HP (Mercury Interactive)

I
It is a web based application
FOLLOWING ACTIVITIES ARE PERFORMED IN QAULITY CENTER:

1. Is a repository(Requirements, Test Cases, Test Results and Defects)


2. Is a management tool (Traceability Matrix, Test Execution)
3. Is a defect reporting and tracking tool
4. Is reporting tool (Reports and Graphs for Test Results and Defects)

Ij OTHER DEFECT TRACKING TOOLS:


Bugzilla, Dtracker, Issue tracker, Clear quest and Cdets

VERSIONS OF QUALITY CENTER:


8.2, 9.0, 9.2 & 10.0
TEST DIRECTOR: ·~: '·
j.

is the earlier version of Quality Center !

I versions of Test Director:

II
5.0, 6.0, 7.0, 7.6 AND 8.0

QUALITY CENTER COMES IN TWO COMPONENTS:


A) Site Administrator:
It is to configure the settings in Quaiity Center like creating Domain, Project,
Project Users and their Privileges is managed by the Quality Center administrator
Accessing Site Administration:
HTTP://SERVERNAME/SABIN

B) Quality Center:
Accessing Quality Center:
HTTP://SERVERNAME/QABIN/ST ART.HTML
Login Page consists of the following:
USER NAME:
PASSWORD:
Authenticate
·DOMAIN:
PROJECT:
Login ·
If the User Namc.and Passwords provided are valid then the domain(s) and project(s) to which the user is associated
will be fetched.
NOTE: One user can be associated to one or more than one projects in a given ,-.-

domain and also can be associated to one or more domains

QUALITY CENTER MAINLY CONSISTS OF 4 COMPONENTS:


1. REQUIREMENTS:
Is to store the customer Requirements.
There can be two of Requirements created in Requirements tab

Mr.Venkat (Sr. Test Manager) Page 99 of 118 ~

; -

~
~LiveTech
wlino sof•h""
liufy

A) NEW REQUIREMENT:
New requirement is to create a parent or sibling to the existing requirement
Navigation:
REQUIREMENTS --> NEW REQUIREMENT

B) NEW CHILD REQUIREMENT:


Is to create a requirement within a requirement
Navigation:
REQUIREMENTS --> NEW CHILD REQUIREMENT
I
We can create any number of Requirements based on the project Requirements
THERE ARE 4 VIEWS IN THE REQUIREMENTS TAB:
A) REQUIREMENTS TREE:
Will display the Requirements in the tree format
Will be able to create the Requirements from Requirements tree
Navigation:
VIEW --> REQUIREMENTS TREE

B) REQUIREMENTS GRID:
Is to display the Requirements in a tabular format and we cannot create the Requirements in this view.
Navigation:
VIEW --> REQUIREMENTS GRID

C) REQUIREMENTS COVERAGE:
Can create the Requirements and also is used to map the Requirements to the Test Cases to perform Traceability
Matrix to ensure the amount of coverage in Test Execution with respect tot he Requirements
Navigation:
VIEW ->> REQUIREMENTS COVERAGE
MAPPING THE REQUIREMENTS:
Select the requirement, and select "select tests", the Test Plan tab is displayed on the right hand side of the screen,
navigate and select the Test Case(s) and click on left arrow.
NOTE: We can have one or more Test Cases or Test Scripts to a given requirement.
D) COVERAGE ANALYSIS:
Is to analyze the Requirements post execution, the status of the requirement is displayed with complete analysis with
the graphs and the numbers.

REQUIREMENTS GENERAL Y CAN HAVE DIFFERENT STATUS:


A) NOTCOVERED:
Is a default status of the requirement, when a requirement is created and no Test Case is associated.

B) PASSED:
When all the Test Cases associated with the requirement are executed and have the status as passed

C) FAILED:
When at least one Test Case is ended in a failed status for a given requirement
D) NOR RUN:
Test Cases associated when not yet executed.

E) NOT COMPLETED:
A partial:y executed Test Cases (at least one Test Case not executed)

2. TEST PLAN:
-~~-
Test Plan tab is to create and >tore manual and automation Test Cases.

CREATING A MANUAL TEST CASE:


FIRST CREATE THE FOLDER STRUCTURE.

~----

-~­
Mr.Venkat (Sr. Test Manager) Page 100 of 118 i
-:-
~llveTech
fiulj ttsthJn i<>l•ti•••

NAVIGATION TO CREATE A TEST CASE:


TESTS -->NEW TEST

Specify the name of the Test Case and specify the Test Case description and in the design steps create the steps for
Test Cases (Step Name, Step Description and Expected Result)

NOTE: Creating Test Cases from Quality Center is not preferred as the server (QC) might get slowed
down and might crash, hence the Test Case design is preferred in external sources like MS Excel and MS
Word documents.

UPLOADING TEST CASES FROM MS EXCEL:

Specify the folder path in the excel document to which the Test Case have to be
uploaded, every folder should be preceded with a backslash (\)

EX: \INSURANCE\HEALTHINSURANCE

Select the Test Cases and go to Tools and select "Export to Quality Center".

Following are the steps:

STEPl: Enter the QC URL and click next


HTTP://SERVERN AME/QCBIN

STEP2: Enter the User name and Password and click next

STEP3: Select the Domain and Project and click next

I STEP4: Specify the location where the Test Cases have to be uploaded
SELECT "TESTS" AND CLICK NEXT

STEPS: Specify the map name select "Create a New Map" and specify the map name
and click next

STEP6: Map the Quality Center fields with the excel fields and click next

STEP7: Is the process of uploading the Test Case to Quality Center

STE;P8: Click Finish

QUALITY CENTER INTEGRATION WITH QUICK TEST PROFESSIONAL:

To connect to Quality Center from Quick Test Professional, in quick test:

Navigation:
FILE--> QUALITY CENTER CONNECTION

STEPI: Enter the URL and click Connect


STEP2: Enter the User Name and Password and click Authenticate
STEP3: Select the Domain and Project and click Login

After the connection is established, we can see the tests to "Test Plan" tab of quality center or we can
open the tests from Quality Center for enhancements for execution.

3. TEST LAB:

f--

Page 101 of118 i-


~

Is the place where the Test Execution is performed:


MANUAL TEST EXECUTION PROCESS: I
I
Create the folder structure and create a "Test Set"
NAVIGATION:
TESTS --> NEW TEST ~--
NOTE: A Test Set is a collection of manual Test Cases or Automation Test
Scripts.

MAPPING THE TESTCASES TO THE TEST SET:


Select the Test Set and click on "Select Tests", the Test Plan tab would be
displayed on the right hand side of the screen, Browse the folders and select the Test
Cases and click on left arrow(<--) executing the manual Test Cases: This can be done in 2
ways:
A) RUN:
When selected, only the selected Test Case will be executed
B) RUN TEST SET:
When selected, all the Test Cases associated with the Test Set will be
executed one after the other in a sequential order.

MANUAL TEST EXECUTION PROCESS:


Select the Test Case in the Test Set and click on "Run", manual test runner will be
displayed, click "Begin Run", complete steps of the Test Case will be displayed with the
Step Name, Time and Date, Step Description, Expected Result and a Textbox to capture the
actual result.
Perform the operation on the application by going through the step description and compare the actual response from
the application with the expected result, if they are matching, select "Pass Selected" by updating the actual result
and after ali steps are completed click "End Run"

If the expected is not matching with the actual result, click on "Fail Selected" and click New Defect, a defect
template will be displayed and fill in all the necessary attributes and attach the snapshot of the defect screen and
click Submit, there would be a Defect ID generated by Quality Center and the reported defect will be uploaded in
Defects tab.
NOTE: Based on the status of the Test Cases in test lab, the status of the
Requirements will be updated in the Requirements tab of Quality Center.
I
AUTOMATION TEST EXECUTION PROCESS:
Create a Test Set and map the Scripts to the Test Set created and specify the "Host Name" on which the test has to
be executed

When performed run on the selected Script, Quality Center will by default launch the Quick Test Professional and
will load the Script qnd will update the status of the test in Quality Center.

NOTE: To ailow Quality Center to launch quick the following configuration has to be done in QTP:
Navigation:
TOOLS--> OPTIONS--> RUN--> ALLOW OTHER HP PRODUCTS TO RUN TESTS AND COMPONENTS.

4. DEFECTS:
Is to store and track the Defects that are reported in the Test Execution process done in test lab. The
Defects reported from test lab are also stored in the Defects tab.

We can also report Defects from the Defects tab, but this is done there is no related test case for the
defect identified.
GENERATING REPORTS AND GRAPHS:
We can generate reports and graphs in Quality Center for the Requirements, Test Results and the Defects.
Navigation: ANALYSIS -->REPORTS and ANALYSIS--> GRAPHS

~---

Mr. Venkat (Sr. Test Manager) Page 102 of 118


~!CWW'T'P'"II!A IWniBIIIIII~·"'QP ~IOO.Ia!~'<f!:G!.'-"'iO!il:a~lfJ;i.Ur.ii!.IJIWW'~~IIIIIIIIIICIIill!!isr"PPJ.W?!HM'i ~~~---
1
N'tMI m:ultll• WM - ce••p•IWIC!i!!!I!W4! gppr lllillillllliiiiEtt"'! M,'flllll9fW!ISftijjlii-

[-HP ~-~~~
--------~~~__ _____ *....c
3:
'""!

<
(1J

~
sa~ l
,.__ ~_
-----------------

,- :-==::\

C'D
!:?..
flc&u nJ ob CQ c use.( ,T~ l~t~c.~ f:t
. l
_.-...

~--·-
C/)

""' ~~

\- 1/Ze 'I)JiJ<M~ ] r=
.......J
(1J

-3:
(/)
c Y€.a}e DCir0oJ '() r· A--0 o s e.& I f'R._-5, u...J.~~ ~u~rern~
P:> - CrEcJ--C rr~·ecJ:s ~A-DD &Q.B
::l
P:> L A-DO j: 1<-.S
,2. A-nn IO T-est s Ul.A.lct 'Y r'C.s US';:J 1'€.8-t- Lob
(JQ

~ - ere~ U<.Sevs 3 • A-00 3o To+ Cc..J~ US~?j r~s1 ~


- F)-S~ijD {JYojecJ:s Te..s+ P k&t 4 · l"-'FV+ 3:::::>
T-e.s+ CO-d'~ Ub•~ -£?c~
frob T £s+- & c~cu-. o_s 5, rnu...p P :':3
Pr cH v c.Jf' / ~')E' a. c_h <~E CLS <> .o;
t-es+-~
·ADo Tes-t- c~ €J - wr'\-0 ~u·~
se ss :m rvxJ rcJ--e. y-p..t_(. ce 'Dc.>-p p ,· '?J w; H, ~0; le-#'1Jl.k

,Se..rve ,. 1Y1a...i~1..~ce_
- .£_ .t x..e..u....*= yes!- CO.d~ u.s j. '?J T e .s+ ~
"1' Qapat Hl Pe,b-ecb lt.s I '-'::) \€JJ- ~
Limr..t<.S~
F.,-- o.rne Wcvt:.. c~·CY) ~+ i0 ,()e,bec_Jj
g. A c..ts;~ ·res+~
~CMh .T€.st- Lob
'
<i. Deje-c..+ iapCT(h G~r-oJ,·~ (.{j,·':J oe-&cC)
fdck o..u.d. -Poe.Pd V~-S - "Tt:.s-1- Ex: -e c.uJ-ion
' ', i 6. s; l.YI'(Jd.S F x.-e Whi7V) CA....S I~ TEJ+
Tc:..--b
f.s,b
nokt.b~e o~c.K. vp Oe,fec)- ~Ufh ~·
.__;' /1' .f rG4v-e_ ~~.
s·k CO->~~r-~~ &elf,yP ' G-Jo{/'-- (
'"d
Pl
r>evec~s l /
-

0
t2€p~W--,;'-j,_,.-/
\- oe,fe.cl--
I D~cl-- ~';J~'
I.;.)
'-

--
0
"""l
'-
00 e-1-c \_..
~'

::;;~,~~:.='"'-"-";:;--...;_:__..: __ ,. __ ::.::..:.-;.;.,':_.;.;-;_;,.:_:..;;.:.:.·:-=.:;;;...o..:_, . ...;.;_ __ .-

·--r-r·,. rlr 11· ·


·-·-·· ··-··-·---·--------- ---~----····· -~~-----·--·---~--

" "'c"'T"~=~~-~~l~ti·-~--r-----
:_n:=:.~7-:~==:::.. .._.:._.:.. __;__ ... . ·- ... . ::·... .:..;·.. _: _:.:...;.....

rI 1
_, ___. :. .;. .. ~---------"-·--··

·- -~- · nr-~m
QTP Interview Questions
JI
1. Why was Automati~n used in the Project?
To I<C2ciu ce_ R-e_ .9 re~ sJ:\1) Te~ h'<!j Ep fovt. ! ;
I--
2. Which Framework are you using for current project?

tfy brd._ fro.Me ( Dola. Oriven -t- 1'-~u.xrd Dr-:veJ 1:

3. Where you use "Recovery Scenario"?


ffppL U.~ Crc~:>f1 ru.td ~ up t-l~tJl.,'r;f{
I
4. What is "Active Screen"?
1

5. Where can view the results of the Checkpoint?

T~+- r<,-est.tl t J,v:nJ;w


6. What is the major difficulty you faced while working with QTP?
!· c.vL/Ie 8.-e~h~ 1-yc.LM£ Wotk_., No rrw Q.JJ..d No Resctlt
~; Oe.h4.J fr.flJ-
;}__· CQrP 1:.S fc.Ld-ed +o (l.,_Q_co3 w··~e_ So&e '1 ~ =-(Jy;LkJ.'c.n ahiec.t;.
Sol . v,· ( i---4&J ubjE?J rYJ(.>AGv-er CtJ...td C£n}q_c} HP Suppa/: L re,.st- La_o__~
,3 · SH Lt. cJ1 rc/Lv d. c-h<./'1 I SS u E;j .
sc t_• L~+ pyc_:pevJ::t
7. Write Script to retrieve data from the Database?
s·£:t ob;'f<s = C®k q0J·ed l t' A DOQ!). &cord_Set ':)
ohJ~·op£4 / t.l .Se..tec± ~ Q_cmtJ
~
u.JSktner 11
./
&bJ.CC¥1

~hox obJ'R.,s ( u ~._sfelrte1 l\)c_.-¥ne. ':)

8. Write script for Invoke web Browser?

9. Types of Actions?
j T!jPEJ r· rvOJ 'f{e<J.)~/e_
.t. R. e..w~ /e_
3. 'Exfe¥~
10. How you declare "Constant Value"?

lt_SI~ •
f-------
c
l\lr Venkat (Sr. Test Manager) Page 104 of 118 f--
~
l==
e_:
L
~livetech fiufyltJtilrSsof>tW<o

11. What is "GetRO and GetTO" property'?


CfeTTo rr,jle¥~ : ra sct Obie'* f'Ydpe-rh·,.s <Yfl f'.,<2.p<Js:te><J Lm"""JoJc
~
(\t'J f{o
-m
f'r'F>XJ:t :
o1.l Pr•pe•li~ c~ obiecl ( yfJ"'-'d,.:tu;J :t-llLL+
12. Can you explain the AutomatiOn Process you are following m your comp':iny. -::::1
Dv~·, ~~ J..
P=i'-(bh'e,j
. .1!.1
'•

~{(' e s \-e.-a~ 1" o o I [ \J c-luo-FO() .


El--b-ur+ t-S<h r0c.-h'cn
F'(~ lt.bit-- crfo.-.h 'c.fYJ .
13. What is the difference between "Call to Existing Action" and "Call to copy of Action"1

c~ +a t)t•'s h_j ftc!,'c¥> : }Q.eo. J (}()~

a:U{ -/-tl C..opj oP A-d&> : R&d. cutJ (J'<l',Je_.


14. Difference between WebTable and Webltem

~To-b/e.

15. How to close Pop Ups during Runtime


u.s~ shill obJ~ech
s<U: obJoheJJ. = c·~ c!·~.Jec/;( ~~ V05Cnpt' &he.Lt ~
"h,"c.s 1--)e.tt. f)(")
. ow o elet e cooki es
t d
'-<! ,~pup '' rn-es.SOfJ.e_ 'f
• '
-[im-e. •<...t .5€a'Y)JJ

1AJ£.~u<h'l ob..J·ed:
16 H
us' :3 /
~ebvJ-J· I · ()QLUe_ Coot<:.J'q
17. How to get number characters from given string
Lt.5 ;~? ()')I 0 ~ <.JII)c_}, ~
rru'J.. C~~ csl-o ,f( ~J- ,j
18. How ta handle runtime errors

,-,-

19. What is relative path'? ,_


~
ji--------

:}
;;
_-,-

20. How to check tool tips using QTP'?

-
Page 105 of 118 ~

i ----- --
Mr.V enk.at (Sr. Test Manager)
1
I==

21. Difference between Action and Function


Action
1. QTP Concept
2. Actions require Object Repository
3. Actions require Build l---
Function
1. VB Script Concept
2. Without Object Repository functions can be developed
3. Without Build we can develop functions

22. Runtime Error HandJing (To handle Runtime errors)


l
.l
j
On error resume next

23. All Extensions supported and used in QTP


.mts - Mercury Test Script
.tsr -Test Shared Repository
.xml - Extensible Markup Language
-.qrs - Quciktest Recovery Scenario
.xls - Excel Spread Sheet
.vbs - Visual Basic Script
.mtb - Modular Test Batch
.mst ~ Modular Script Template
.UDL -Universal Data Link
ADO DB - Activex data object database
OLEDB -Object linking embedded database

,1ji. u.sed 'n (QTp

Set obJ' ccn ::: - A.


c__)'fu~db.iC: cr o . CC~V\-.e cJC.n Y
LI \' 4tJaD" J')

get o~ ·COil) -- c ~db;"ecl: (_ 1r ft-OoDC!> • COft\Y>1d4d ':J


8£1 o.bj f\J -- cd-ecb.J·-ed: [ l\ ttDdiJ8· l<.e(uvd.Sel-1 9
cY"&k o.~·ecl- ( ' SGy}'ph';j ·
1
se+ dbi F~o ~
F/t-e<{yJcfc:Mo'b,feo{:J ·

S'-d d\:ll fx CU -::: <.:x~k~e cl- ( 1


r fx eli· A-(JpU~·~ ')

seA: ~- az rp C'rGzk~ec.t- [lt Ltt.tt'cl{,~f:. Ftpp U Gh;;11 ' )

s.&- o~'slvt (_yt:o-k_ ~ 'e_c):; ( L1 h.}SGnpi: · S 4eu_ 11)

Mr.Venkat (Sr. Test Manager) Page 106 of 118


r--
'
t-
l
t
QTP 11.0 New Features
I
· 1. Good Looking and Enhanced Results Viewer
2. Load Function Libraries at Run Time
3. Test Your GUI and UI-Less Application Functionality in One Test
4. Record Support
5. Much Awaited Log Tracking is available now
6. Embed/Run JavaScript in web pages
7. Web 2.0 Toolkit Applications Support

II 8. Automatically Parameterize Steps


9. Silver light Add-in
10. Extend WPF and Silver light Support
11. Use Extensibility Accelerator for Web Add-in Extensibility Development
12. Avoid Downtime Due to License Server Failures

1. Good Looking and Enhanced Results Viewer

The new improved results viewer provides an executive summary page with summary data, pie
charts and statistics for both the current and previous runs and a quick link to the previous run
results.

~·St-~1: ........
~.,o. 4::€J.,.~:on

S."2'!V2010. :::O·V:U
«):01- (:11(0

2. Load Function Libraries at Run Time

With the help of LoadFunctionLibrary statement. You can now load a function library when a -'.-
step runs instead of at the beginning of a run session.
~--­
3. Test Your GUI and UI-Less Application Functionality in One Test ~
,-,-
~

Since QTP is integrated with Service Test, you can now test your GUI and non-GUI based apps
in a single run.

-·-
~--~

Mr.Venkat (Sr. Test Manager) Page 107 of118


4. Record Support

For FireFox is now available.

5. Much Awaited Log Tracking is available now

QTP 11 is capable of receiving Java or .NET log framework messages from your application
which can then be embedded in the run results.

6. Embed/Run Javascript in web pages

You can use the new EmbedScript/EmbedScriptFromFile and


RunScript/RunScriptFromFile functions to embed JavaScripts in all loaded browser pages.
You can use these scripts to perform operations on, or retrieve data from, the browser pages in
your application.

7. Web 2.0 Toolkit Applications Support

QTP 11 now supports Web 2.0 Toolkit Applications out-of-the-box similar to any other add-ins.

8. Automatically Parameterize Steps

You can instruct QTP 11 to automatically parameterize test steps at the end of record session.

9. Silverlight Add-in

To test objects in Silverlight 2 and Silverlight 3 applications. [After installation, Silverlight Add-
in is displayed in the Add-in Manager as a child add-in under the WPF Add-in]

10. Extend WPF and Silverlight Support

You can use WPF and Silverlight Add-in Extensibility SDK to develop support for testing third-
party and custom WPF and Silverlight controls that are not supported out-of-the-box

11. Use Extensibility Accelerator for Web Add-in Extensibility Development

12. Avoid Downtime Due to License Server Failures


~-
Useful for concurrent license users. With redundant license servers you can create failover, so
that if your main license server fails, your remaining servers maintain availability of your
licenses without causing any downtime or loss of licenses for users.

Mr.Venkat (Sr. Test Manager) Page 108 of 118


~liveTech
linn finfy us sof•IW.,

Flat File Scripts to Practice (FSO)

1. Create a Folder

DimobjFso

Set objFso==CreateObject("scripting.FileSystemObject")

objFso.CreateFolder "C:\LiveTech"

2. Check if the Folder Exist or not? If not create the Folder

Dim objFso, myFolder

myFolder=="C:\LiveTech"

Set objFso==CreateObject("scripting.FileSystemObject")

If Not objFso.FolderExists(myFolder) Then

objFso.CreateFolder (myFolder)

End If

3. Copy a Folder

Dim objFso, myFolder

myFolder=="C:\LiveTech\Qtp"

Set objFso==CreateObject("scripting.FileSystemObject")

objFso.CopyFolder myFolder,"E:abcd"

4. Delete a folder

Dim objFso, myFolder

myFolder=="C:\LiveTech"

Set objFso==CreateObject("scripting.FileSystemObject")
-:~-

objFso.DeleteFolder( myFolder)

2nd r
IL_____
~

Dim objFso, myFolder

my F older=="C:\LiveTechQtp"

Set objFso==CreateObject("scripting.FileSystemObject")
~-­

Pagel09ofll8 '
r-
,____
Mr.Venkat (Sr. Test Manager) g
~
~liveTech
m·tfy sol•timu
ltslin!l

If objFso.FolderExists(myFolder) Then

objFso.DeleteFolder( myFolder) ·....

End If
t--
5. Return a Collection of Disk Drives

Dim objFso, colDrives

Set objFso=CreateObject("scripting.FileSystemObject")

Set colDrives=objFso.Drives

For Each oDrive in co!Drives

Msgbox oDrive

Next

6. Get available space on a Drive

Dim objFso.

Set objFso=CreateObject("scripting.FileSystemObject")

Set myDrive=objFso.GetDrive("D:")

Msgbox myDrive.AvailableSpace/(1 024"3) & "GB"

7. Creating a Text File

DimobjFso

Set objFso=CreateObject("scripting.FileSystemObject")

objFso.CreateTextFile ("C:\LiveTechQtp !.txt")


j
objFso.CreateTextFile ("C:\LiveTechQtp2.doc") l

objFso.CreateTextFile ("C:\LiveTechQtp3.xls")
.-:-
objFso.CreateTextFile ("C:\LiveTechQtp4.pdf')

Note: We can Create other files also, but they act as Text/Flat Files

8. Check if the File Exist or not? If not create the File

Dim objFso, myFilel ,myFile2, myFile3, myFile4

-~­
i
Mr.Venkat (Sr. Test Manager) Page 11 0 of 118 -~-
F
~liveTech
IW<fl tUn"'"'"""'
Its
c
myFile 1="C:\LiveTechQtp l.txt"

myFile2="C:\LiveTechQtp2.doc"

myFile3="C:\LiveTechQtp3 .xis" i----


myFile4="C:\LiveTechQtp4.pdf'

Set objFso=CreateObject("scripting.FileSystemObject")

IfNot objFso.FileExists(myFilel) Then

objFso.CreateTextFile (myFile1)

End If

If Not objFso.FileExists(myFile2) Then

objFso.CreateTextFile (myFile2)

Endlf

If Not objFso.FileExists(myFile3) Then

objFso.CreateTextFile (myFile3)

End If

If Not objFso.FileExists(myFile4) Then

objFso.CreateTextFile (myFile4)

End If

9. Read Data Character by Character from a text file

Dim objfso, myFile, myChar

Set objFso=CreateObject("scripting.FileSystemObject")

Set myFile=objFso.OpenTextFile("C:\LiveTechQtp.txt",l) '1 for Read, 2 for Write and 8 for Appc11d

Do Until myFile.AtEndOfStream=True

myChar=myFile.Read(l)

Msgbox myChar

Loop

myFile.Close

Page 111 of l 18
l - ------
Mr.Venkat (Sr. Test Manager) g.._____
~liveTech
ktfylulioflwlltti.Jo,

e;

Set objFso=Nothing Jj
~
~
10. Read Line by Line from a Text File }
i

Dim objFso, myFile, myChar


!
l
Set objFso=CreateObject("scripting.FileSystemObject") j
Set myFile=objFso.OpenTextFile("C:\LiveTechQtp2.txt", I) 'I for Read, 2 for Write and 8 for Append !t
j
Do Until myFile.AtEndOfStream=True

myChar=myFile.ReadLine I
Msgbox myChar I
Loop
I
myFile.Close I
Set objFso=Nothing I~

11. Data Driven Testing by fetching Test data directly from a Text file.

'************************************************************************************
*
'Test Requirement: Data Driven Testing by fetching Test data directly from a Text file.

'Author: xyz

'Date of Creation: 24-08-2010

'Pre-requasites:

'abcd.txt (Test Data File)

'Test Flow:

'Create File System object

'Open the file with Read mode and store reference into a variable

'Skipe the first line


I I
'

;:;-

I
'Read line by line and split the Data ..

'Login Operation

'Form Looping and pass Parameters

Mr.Venkat (Sr. Test Manager) Page 112 of 118


F
I
'************************************************************************************
*
Dim objFso, myFile, myLine, myField ~-
Set objF so=CreateObj ect("scri pti ng.F ileSystemObj ect")

Set myFile=objFso.OpenTextFile("C:\LiveTechQtp.txt", 1) '1 for Read, 2 for Write and 8 for Append

l myFile.SkipLine
§

!
l
Do Until myFile.AtEndOfStream =True
~

Ii myLine=myFile.ReadLine

I
1 myFieid=Split(myLine," ,")
~~ SystemUtil.Run "C:Program FilesHPQuickTest Professional\samp1es\flight\app\flight4a.exe"
u
,~~ Dialog("text:=Login").Activate

Dialog("text:=Login").WinEdit("attached text:= Agent Name:").Set myField(O)

Dialog("text:=Login").WinEdit("attached text:=Password:").Set my Field( 1)

Wait 2

Dia1og("text:=Login").WinButton("text:=OK").Click

1
l Window("text:=Flight Reservation").Close
I~ Loop
I myFile.Close
I
I l
u
Set objFso=Nothing

12. Write Data to a Text File


i
I ~ Dim objFso, myFile, Result, a, b
! ,-,-
I a=lO: b=20

iI Result=a+b

Set objFso=CreateObject("scripting.FileSystemObject")

I• Set myFile=objFso.OpenTextFile("C:\LiveTechQtp3.txt",2) '1 for Read, 2 for Write and 8 for Append

I• ~
myFile.WriteLine "Addition of a, b is: "&Result
~
i Page 113 of 118

I
'
Mr.Venkat (Sr. Test Manager) I
~

~
E
~
myFile.Close

Set objFso=Nothing

13. Delete a Text File

DimobjFso

Set objFso=CreateObject("scripting.FileSystemObject")

objFso.DeleteFile("C:\LiveTechQtp.doc")

Set objFso=Nothing

L _____ _

Mr.Venkat (Sr. Test Manager) Page 114 of 118


I ·-~-
t_ ______ _

r--
~liveTech
tiNfyltslilflsdllima

14. Check if the File Exists or not? If Exists delete the File

Dim objFso

Set objFso=CreateObject("scripting.FileSystemObject")

If objFso.FileExists("C:\LiveTechQtp l.pdf') Then t-


objFso.DeleteFile("C:\LiveTechQtp.pdf')

End If

Set objFso=Nothing

15. Calculate size of a Text File

DimobjFso

Set objFso=CreateObject("scripting.FileSystemObject")

File_Size= objFso.GetFile("C:\LiveTechQtp.txt").S ize

Msgbox File_Size&" Bytes"

Set objFso=Nothing

16. Capture Customer Names from 1 to 10 Orders in FR and export to a Text File

*****************************************************************
I 'Test Requirement: Capture Customer names from 1 to 10 orders
J
'

II 'and export to text file

'Test Flow:
I
g 'Create im object in File system class
1
I 'Open the text file in write mode using File system object

I 'Login Operation
I 'Form Loop to open 1 to 10 orders

I
I
'capture the Customer names and write to external text file

'*****************************************************************

Dim objFso, myFile


r:--
r;

t--

Mr.Venkat (Sr. Test Manager) Page 115 of 118


c=
~liveTech
wt.n;,s ftulj ttslilln

Set objFso=CreateObject("scripting.FilesystemObject")

Set myFile=objFso.OpenTextFile("C:\LiveTechQtp.txt",2)

myFile.WriteLine "Customer Names"


l---
myFile.WriteLine "·---"

IfNot Window("Flight Reservation").Exist(3) Then

SystemUtil.Run "C:Program Files\HP\QuickTest


Professional\samples\flight\app\flight4a.exe","","C:Program Files\HP\QuickTest
Professional\samples \flight\app", "open"

Dialog("Login").Activate

Dialog("Login"). WinEdit("Agent Name: ").Set "LiveTech"

Dialog("Login").WinEdit("Password:").SetSecure "4c9e05a626f9b6471971 fb 15474e791 b28cc ledO"

Dialog("Login").WinButton("OK").Click

Endlf

For Order_Number= 1 to 10 step 1

Window(" f) ight Reservation ").Activate

Window("Flight Reservation").WinButton("Button'").Click

Window("Flight Reservation").Dialog("Open Order'"). WinCheckBox("Order No.").Set "ON"

Window("Flight Reservation").Dialog("Open Order''). WinEdit("Edit'').Set Order_Number

Window("Flight Reservation").Dialog("Open Order").WinButton("OK'').Click


"- ' · -
:~
c,

wait 2

Customer_Name = Window(''Flight Reservation"). WinEdit(''Name:'').GetVisibleText()

myFile. WriteLine Customer_Name

Next
~.·-

myF ile. Close


~-----

Set objFso=Nothing -··-


'

17. how to verify update Order behaviour in the Flight reservation application and how'to pass
multiple values from the textfile

~-----

Mr.Venkat (Sr. Test Manager) Page 116 of 118


Option explicit

Dim fso,f,s,arr,strStatus

Set fso=CreateObj ect(" Scripting. filesystemobj ect")

set f=fso.OpenTextFile("E:\Records.txt", l)

While not f.AtEndOfStream

s=f.ReadLine

an=split(s," ")

Window("Flight Reservation'').WinMenu("Menu").Select "File;Open Order ... "

Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"

Window("Flight Reservation ").Dialog("Open Order"). WinEdit("Edit").Set arr( 1)

Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

strStatus = Window("Flight Reservation").WinButton("Update Order").GetROProperty("Enabled")

If strStatus="False" Then

Reporter.ReportEvent micPass,"Update is Disabled","Test is pass"

Else

Reporter.ReportEvent micFail, "Update is Enabled", "Test id failed"

End If

Wend

f. Close

Set fso=nothing

18. Descriptive Programming

*****************************************************************************

Set objFlyFrom =Description. Create

objFlyFrom("Class Name"). value= "wincomboBox"

objFlyFrom("attached text").value ="Fly From:"

Set objFlyTo =Description. Create

Mr.Venkat (Sr. Test Manager) Page 117 of 118


~liveTech
firtfy wlino '"'""""'

objFlyTo("Class Name"). value= "wincomboBox"

objFlyTo("attached text"). value= "Fly To:"

'Set objwin=Description.Create
l----
0

..
v-.._
'objwin("text"). value=" Flight Reservation"

FlyFrom_IternsCount = Window("text:=Flight
Reservation"). WinComboB ox(objFl yFrom). GetitemsCount

For i=O to FlyFrom_ItemsCount-1 step I

FlyFrom_Item = Window("text:=Flight Reservation"). WinComboBox( objFlyFrom).Getltem(i)

Window("text:=;FJight Reservation"). WinCcmboBox( objFlyFrom).Select FlyFrom_Item

FlyTo _ ItemsCount=Window("text :=Flight Reservation"). WinComboBox(objFlyTo). GetitenisCount

For j = 0 to FlyTo_ItemsCount-1

If strcomp(FlyFrom_Jtem,Window("text:=Flight Reservation").WinComboBox(objFlyTo).Getitem(j))=O
Then

Reporter.ReportEvent micFail, "step!", "Item equals in Fly To"

else I
I
fi---

Reporter.ReportEvent micPass, "step I", "Item equals in Fly To~'

End If
~
Next
I
rl
-rJ-

Next

'*****************************************************************************
I
I
I
I
i
.----
t

I
r--
~
Mr.Venkat (Sr. Test Manager) Page 118 of 118 L__

i
E

r
Tts.-1:: scri p-I:

J· 1 ...,

[; -l)·
~
1· A S .s u c, c..it

~ · OuY~ 1'\._(_{N f,'"'\2

.3 . f\ c__l-if) r r() (JE'rt h' -Q,J

b.

~~·;-
c'
"e
~
~
F.
~-,-

~------

.
L_
;;__:___:_:_::_
._ ~

·. !
Dchla. -hlbe · ArJot.S~e.ct. u Inpctt~lf

~-lab Ie · I"-jlalsh~ tt \ \sf'.(Ler\ L,v' H £C i-f LAJJ \ l< P ,-\ l ~ <.<: >< Ls ~1 J, ''-'- "f ~t 1
fZo<.J ecu.l: =~re, c; e~-&luzct ( ''J"''rthobh / ). Get~fu.~
For ,··:.::. f +-o . ' CCLVLt:_
y- c_....._,
._ J L-..,
s''-t' I
l-
DJz k,hl e_ • Set CJ.jtrtvJ:-~ (_ lj . •
S';tjo b""~ ~.th 'L . lLurl u f2r··le pc:Je. t,

di~.L2:f ( u Loa~ "1 ~~)- w ~--~~-e~ ( t t A-EJeL...-i NcJI1e : ~~). Sek Dw-lz.Jc-bfE· v"-.L..e_

L~ C' ~I.!J · W<"l.,eJ,'-t ("NSv¥c;l: t'). sd


c~~ ir l\ f¥c~(J
ocJuJccJJ--e . \[ 0-...~ '

d.i~ cLl~·l,_ li.J ., ~ ,l._b~q


t (_ U () k._ IJ . c1_t·de._ (t~p~~~ r 11 -~J-4JJa!_}

/2Qpvrk:; · l&.rx1rf:e.~...reJ N-l..Cp,---e,-~ u l.~' ~":j La:r'c,. /~ 1"- J-eua. •-5 f=-i-;s 11

d.cJc:ef<>b [-c' · V.:-Lc"{_ ( t l.fe.*. rf'-N_/ b '_; II i ~~ c::(~ 1j ~ !l -kf(#- ~~~ {Jc>-5.J /i

,: ' ~ 1 tJ ,, ~
1
, I .\ r 1 · lr)
r· Ltc.)'t_rt ~c)Hie-n-;:t, j · Oe»~
1
\..o-..._) l>cl9 L

{J__Qfcd·ct;· R.c.-rcxt E:-~~_,cl- N


• '
cFc<-l.(/
(I ·e-,'
t.rf:J·v?,J
Lc'J-{4..; ![ J-cA- ;.5 ~~(It

b ,Jq_ h~]K? . \(c::_.kt't' (_ \\ ,f-c-;4- ~ l) t~) r (


.I
\t f 'L.p LJ+~ ('.) :::- i r ~ •s -,:e.; ( h

fJQ>cT
1
t >cf c.-'f t {)o-tcz ~ f-est (~.

pc:.~+d'biE, -[,x.pc:rt-.SLu.l· \.\ \ ~-t€_f~ ' reo~L~\~16 ·xJ.8 ~ tlr¥ufdo/-q h

:_ _____ _

'---
L -
r-
~
1-

>'.
l~
Q
Li
I;
j t'i-

I !1
I
u

,, --

q
f~.;--

i'- --
~-c,.-_--

'
(f)

(JJ c~{'_ mo~rejr~J-s~·QS


l~J Co fD 14 TeJ.t- ~n Fut~ OU--tl
()o.Lbfl'. c)_{clc._ UVJ \I ~, Vi.u'r

~ ob S--€M..re__ TCCJ .-1- LCj (Ftr- ~tt l 0 ~ fir-e_

L-
1
~
11

~
~
~
~

Li

L
-:-
f
r~

~
b-------
"~
~-
[T---
Tuk-tvrew q;ue.sf-r(ns OY) ma.nuo.l--re.s.~~
,___,

CLtSbev-
v ~-w flrt:Jf:'~e.
fd."-t f-rotJ.'te
- ch~e pc~-~ J

~ f~ ·-'-;:> lo.pJ<,p spe.c.·fi~ --") c,-J.e.. ~


pnce_

cyuc.~
\ \
r~~ rY1ade__

.~Lirr··~
t=J

DefO\+~ ~~.

f4> ~e ~'-,shc:-hUJ.
O::.iH .(j\.b -Q. -
~ ¥liclb.._ ~

A-.i...v~ '""-.
__n_~~
!'\....<.._~
I

s-~o ~~tiD
·---·---

I ~Pi
~-­

~
~ ....

ff
h,.oJ &€¥ ( " Pf'lc_ hli : J ·pc'!Je_(," p rnc 1 nc. J . tvebeJ,f (" li5E'~•dJ ·set '~r"
braD6er (_" pm( i~ c.. j . Puge L" Pm c l "c . j .~t ('' PaM «.brd J· sd; " Re.~ <"
b "cwser C" P""c ::nx ·
1
'.) • P* (' • pr>n c_ 1N c· ~ · u.h h4~ (" Swb"·;ej · did:_ .

c
bm..wer "pm ( CJf) ( • j . pc~ L"~,'). r ra...,£ (_ cr~ j ' L'u..K /1

• ( t{ E-- L 'f- pro~~~ IJ· c&"u._


.b /'C:tcJS<?r L"
r p<Y)(_ Ih·. (. . J
o)
~ J •F '~"-(_'. c {.)0h/J. '6
.p <(} e.l!'<f\l£wPc"':3e_t.,l •))
I
1'/;--
. h£6 ""'
(_ '
1
pht:Jpe /:_)· St?Ieu-
b.,ause,r (" p JY1 c :r~ C . .") • pOj'e. (I' ~j F rc.vo,e( " CDedails ;r) . ~~~e "

upcbJ-ec•do=:~
---------

f'l 9~t Nc..ft'le / pc_.s.s 0-Lyd


\)~ 1\..o.D-vc_:J
TY7v~:J:

-~~ee_Jd_ fcuno.r 9)
pc~~,J_
~·~q\ §ih~l

--~--~-----.

-6-1
I/ .

.y,'ew fh'*Ce
-t;:Lf- ~·~ k
€h~ e:_ "(Jc~( ~iL
r
UYuW_ cvc::b--
\jie.....l ~

Qe~-' 'fv-Dt8~/ CV'-'~~ J ~~~-I.


v~Lw ~~
~('J~

. v~·d..Jc ~:Jk
8
ll <6- t\J} (i<h&/
(-lhJo)
~~v--

~td ~cLeJ- L_D


9fL~
po1-) t=-.c<.+--f\1
(bLf
s-
f?BT
't

t-
r:

~~~, .~.-j~-
u[__
I'VI£.scSL<je -

', ~
IOI~:i @ r-
S, r.f" t·l\..efl1c I:J {Jtp~ho ~
f,
~
Fr~ )~~t~
. [
' p.e#PJ/ f :> OJ L'~v-i 1

.-GJ
p"~c5v=f'F- \

You might also like