You are on page 1of 75

Bo

ok
ie
w

ev

Pr

ew

http://KnowledgeInbox.com/store/

Pr

ev
i

QTP Descriptive
Programming Unplugged

Bo

ok

by Anshoo Arora and Tarun Lalwani

http://KnowledgeInbox.com/store/

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

QTP Descriptive Programming Unplugged


Publisher: KnowledgeInbox
Author: Anshoo Arora & Tarun Lalwani
Editor: Vicki Watson
ISBN: 978-0-9836759-2-1
2012 KnowledgeInbox. All rights reserved.
Printing History:
Nov 2012: 1st Edition

ew

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form
or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except
as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the
prior written permission of the Publisher, or authorization through payment of the appropriate percopy fee to the KnowledgeInbox. Contact online at KnowledgeInbox.com/contact-us/

ev
i

6RXUFHFRGHVGLVFXVVHGLQWKLVERRNFDQEHFRSLHGPRGLHGRUGLVWULEXWHGZLWKRXWSHUPLVVLRQIURP
author/publisher by including the below reference comment header.
'Source code taken from "QTP Descriptive Programming Unplugged"

Pr

'By Anshoo Arora & Tarun Lalwani

'Download source from KnowledgeInbox.com/demos/QTPDPUnplugged_SourceCodes.zip


'Website: KnowledgeInbox.com/books/qtp-descriptive-programming-unplugged/

Bo

ok

This document also contains registered trademarks, trademarks and service marks that are owned by
their respective companies or organizations. Publisher and the author disclaim any responsibility for
specifying which marks are owned by which companies or organizations.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS
OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED
BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT
BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES.
IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON
SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES
ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK
AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE
AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET
WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK
WAS WRITTEN AND WHEN IT IS READ.

ii

ii

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

About the Authors


About Tarun Lalwani

Pr

ev
i

ew

Tarun Lalwani is a Test Automation and Solutions Architect and


the author of the two most widely-read books on QTP, QuickTest
Professional Unplugged and And I Thought I knew QTP!. He
has worked on various automated testing projects, utilizing
technologies such as VBScript, VB6, VB.Net, C#.NET, Excel and
Outlook Macros. Tarun is the founder of Test Automation Research
and Labs (TARLABS); a company focused on Test Automation
Products and Services. He is also the owner and lead author for
KnowledgeInbox; a blog and publication house focused on Test Automation. Tarun was
awarded with the Best Feedback Award by HP for QTP 11 Beta testing and his book
QuickTest Professional Unplugged was named the Best Automation Book in the 2nd ATI
Automation Honors awards. A regular contributor on AdvancedQTP and SQA forums,
Taruns work has been showcased on several websites, including www.relevantcodes.com
and www.advancedqtp.com.

Bo

ok

In Dec 2011, HP invited Tarun to its R&D center in Israel for a 4 day conference. The
conference was aimed on taking his feedback on various aspects of QTP & BPT. This
ZDVWKHUVWWLPHHYHU+3KDGLQYLWHGDQ\XVHUIURPRXWVLGHRI,VUDHOIRUIHHGEDFN7KH
invitation highlights HPs interest in getting the user community involved in enhancing
their tools.
Tarun can be contacted at www.linkedin.com/in/tarunlalwani or
www.knowledgeinbox.com/contact-us.

http://KnowledgeInbox.com/store/

iii
iii

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

About Anshoo Arora

ew

Anshoo Arora is an author, Test Architect and software


developer, best known for his Test Automation website,
www.relevantcodes.com. He is continuously researching to
QG EHWWHU ZD\V RI ZRUNLQJ ZLWK 473 VLPSOLI\LQJ DXWRPDWLRQ
maintenance and creating extensible test suites/frameworks. Apart
from QTP, he also works with Quality Center, LoadRunner, .NET
programming, Selenium WebDriver, TestComplete and Web
Technologies. Anshoo is a regular contributor at AdvancedQTP
and SQAForums and is also the Technical Editor and Reviewer of
4XLFN7HVWVUVWFRQFHSWXDOERRN$QG,WKRXJKW,NQHZ473

Bo

ok

Pr

ev
i

Write to him at anshoo@relevantcodes.com or visit his website Relevant Codes at


http://www.relevantcodes.com.

iv

iv

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

Dedication

Bo

ok

Our vision for this book is to share our knowledge and experience with the QTP community.
It is a privilege for us to write this book and we hope that it will reach QTP Engineers across
the globe. But not everyone in this world has the same advantages, let alone the blessing
of education. Millions of children around the world today live life without hope of meeting
their most basic needs, without any education, and without the promise of a brighter future.
Education empowers. Education inspires. Education can help to lead the way out of poverty,
and provide the tools to guide the less fortunate towards a better life.
By purchasing this book, you will help a child break free from the cycle of poverty and gift
them a future full of hope. For each copy sold, we will donate 10 to organizations working
towards the worthy cause of child education. Help us to learn and foster learning.

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

Acknowledgements
From Tarun Lalwani
I actually started writing this book before my second book And I thought I knew QTP,
EXWWKHLGHDRIZULWLQJDWHFKQLFDOQRYHORYHUWRRNDQG,QLVKHGZKDWZDVLQLWLDOO\VXSSRVHG
to be my third book. Finally getting back to this book with another year of experience,
however, meant even more polished content. This book has involved a lot of research
and experimentation with different approaches and has therefore proved even more time
consuming. This, however, means more polished content and greater attention to detail.

ev
i

ew

I would like to thank Anshoo for accepting my request to co-author this book. He is one of
WKHJUHDWQGVIRUWKH473ZRUOGDQGLQSDUWLFXODUIRUPHDVZHERWKVHHNWKHVDPHJRDO
i.e. to share our knowledge with the Automation community.

ok

From Anshoo Arora

Pr

I would also like to thanks my family members who have always been there to support me
during the writing process and even after publication.

Bo

I would like to thank all my clients and colleagues for trusting in me and for giving me the
opportunity to work with them.
A huge credit goes to Tarun, who has always strived for a better QTP community by
constantly helping thousands of people over this course. Writing this book with him has
been an incredible experience and a lot of fun.
I am grateful to everyone who visited and provided their feedback at Relevant Codes; it
was their comments and encouragement which drove me to create the content that exists
today.
$QGQDOO\WRP\IDPLO\WKLVLVIRU\RX7RGD\,ZRXOGQWEHGRLQJDQ\WKLQJZLWKRXW\RXU
support; nothing would have been possible.

http://KnowledgeInbox.com/store/

vii

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

About the Editor


Vicki Watson is a writer, editor and book designer whose publications
have ranged from business books, teacher resource guides and
parental handbooks to childrens workbooks and poetry. After a
career as a teacher and deputy headteacher, she decided to focus on
her love of language and design and set up Callisto Green, a vibrant
and dynamic writing and design venture and small publishing
imprint. When shes not scribbling in her notebook, her many
interests include playing the clarinet, rock-climbing, stargazing and

ew

playing chess.

Bo

ok

Pr

ev
i

Vicki can be contacted by emailing vicki@callistogreen.com or through her website at


KWWSZZZFDOOLVWRJUHHQFRP

viii

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

Foreword
by Meir Bar-Tal

ew

When Tarun Lalwani and Anshoo Arora asked me to assist in the review of this book,
,IHOWERWKKRQRUHGDQGREOLJHG7DUXQDQG$QVKRRDUHWUXHSLRQHHUVLQWKHHOGRI7HVW
Automation; whose contribution to the worldwide community is immeasurable. So, though
the time schedule was tight, I undertook the challenge to make my humble contribution to
this impressive project.

Pr

ev
i

All through my reading I felt that QTP Descriptive Programming Unplugged is one of these
books which make you think: I wish I had this reference available in my last project.
With this third book in Tarun Lalwanis QTP Unplugged series, now co-authored by our
GLVWLQJXLVKHGFROOHDJXH$QVKRR$URUDWKH2EMHFW,GHQWLFDWLRQSRZHURI+34XLFN7HVW
Professional is handed to the Automation Developer like a cookbook.

ok

The book, which could have been easily split into two volumes, leads the reader from the
FRUH FRQFHSWV RI 2EMHFW ,GHQWLFDWLRQ WKURXJK WKH FKDOOHQJHV IDFHG E\ WKH$XWRPDWLRQ
Engineer, to the practical solutions which are the fruit of a sound and thorough research. All
these are accompanied by well suited real-life, easy to grasp and well annotated examples.

Bo

The book is an extensive in-depth compilation with an emphasis on testing Web applications.
It covers both GUI and SOA automation, and it tackles many misconceptions and pitfalls
EHJLQQHUVIDFHLQWKHLUUVWVWHSV7KHQXPHURXVZHOOGRFXPHQWHGFRGHVDPSOHVLWSURYLGHV
ensure that understanding does not remain only at the theoretical, conceptual level.
To me, QTP Descriptive Programming Unplugged marks a very important event in the
annals of automation knowledge. I am sure that the readers of this book will acquire skills
that are rarely taught in QTP courses, and it will serve them as a reference and practical
guide.
I wish to thank Tarun and Anshoo for giving me the opportunity to have a privileged
glimpse into their colossal work and wish you the reader an enjoyable and fruitful journey.

http://KnowledgeInbox.com/store/

ix

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

Automation Architect, AdvancedQTP

Bo

ok

Pr

ev
i

ew

* Meir Bar-Tal is an Automation Architect with over 12 years of technical, educational and leadership experience
in Software Design, Development and Testing. Meir has helped companies establish solid foundations for their
testing activities with a wide variety of software applications and systems and across different technologies and
SODWIRUPV0HLULVDZHOONQRZQH[SHUWLQ'DWD'ULYHQ.H\ZRUG'ULYHQDQG+\EULGPHWKRGRORJLHVDQGKDV
SXEOLVKHGDQXPEHURILQXHQWLDODUWLFOHVRQWKHDSSOLFDWLRQVRI'HVLJQ3DWWHUQVWR7HVW$XWRPDWLRQ)RUWKHODVW
YH\HDUVKHKDVEHHQSXVKLQJIRUZDUGDQDPELWLRXVSURJUDPWRZDUGVWKHGHYHORSPHQWRIDQ2EMHFW2ULHQWHG
automation framework named Sunscrit, a huge project which is still underway. Meir is the owner of www.
$GYDQFHG473FRPRIZKLFKKHZDVDFRIRXQGHULQDQGVHUYHGDVLWV(GLWRULQ&KLHI$XWKRUDQG)RUXPV
$GPLQLVWUDWRUHYHUVLQFH0HLUOLYHVLQ,VUDHODQGFRRSHUDWHVFORVHO\ZLWK+35 'DQGRWKHUFROOHDJXHVWR
LPSURYHWKHXVHUH[SHULHQFHDQGSURGXFWLYLW\ZLWK+36RIWZDUHWRROV.

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

Foreword
by Colin W. Fries

ev
i

ew

,YHEHHQLQWKHWHVWDXWRPDWLRQVSDFHVLQFHEXWZDVUVWLQWURGXFHGWR+3V4XLFN7HVW
3URIHVVLRQDOVRIWZDUHLQZKHQ,VWDUWHGDMREZLWKDQ+3FOLHQW8QWLOWKHQ,KDG
SHUIRUPHGDOLWWOHELWRIWHVWDXWRPDWLRQXVLQJDKRPHJURZQVHUYLFHWHVWLQJWRRO+RZHYHU
I was keen to develop a working QTP skillset as quickly as possible. Interestingly enough,
one of the things also driving this interest was that I was thrust into a situation where I was
the automation expert, even though everyone above and around me knew that I knew about
as much about the topic as they did. Nonetheless, I was expected to produce a working set
of automated test cases as to reduce the manual testing burden of the QA team.

ok

Pr

$WUVW,IRXQGWKDW,ZDVQWYHU\XVHIXODURXQGWKLVWRROVR,GLGZKDWHYHU\RQHHOVHLQ
my position would have done I asked for (and received) vendor training. I spent a week
LQ3DUVLSSDQ\1HZ-HUVH\ZLWKD+3%XVLQHVVSDUWQHUOHDUQLQJWKHEDVLFDQGDGYDQFHG
IHDWXUHVRIWKHWRRO$QGZKHQ,FDPHEDFNWRWKHRIFH,GHQLWHO\KDGDIHZQHZWULFNV
up my sleeve. But despite taking the basic and advanced courses, there were still a lot of
questions and problems with our test suite that needed to be ironed out.

Bo

3ULRU WR DWWHQGLQJ WUDLQLQJ ,G VSHQW D ORW RI WLPH OXUNLQJ RQ 64$)RUXPVFRP DQG
VHDUFKLQJIRUDQVZHUVWRKHOSJKWWKHGDLO\EUXVKUHVWKDWZHUHRFFXUULQJ7KLVLVZKHUH
,UVWHQFRXQWHUHGRQHRIWKHDXWKRUVRIWKLVERRN7DUXQ/DOZDQL$WWKDWSRLQWLQWLPH
Tarun was already a seasoned expert in the test automation space and was particularly
adept at straightening out noobs such as myself. Over the years, he has answered hundreds
of questions from the masses (I include myself here) and has given priceless advice and
insight on everything from resolving syntax errors to developing automation frameworks.
Because of Taruns advice, the issues affecting us were resolved and we were able to create
a working automated testing framework.
$W DERXW WKLV WLPH , DOVR EHFDPH LQYROYHG ZLWK9LYLW +3 6RIWZDUHV LQGHSHQGHQW XVHU
JURXS$VLWWXUQHGRXWP\ORFDOFKDSWHUIRFXVHGRQTXDOLW\DVVXUDQFHVRIWZDUHWKDW+3
had, at that point, recently acquired from Mercury. So I joined the chapter and eventually
became one of its leaders. It was through this avenue that I came to know the other author

http://KnowledgeInbox.com/store/

xi

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

RIWKLVERRN$QVKRR$URUD%\WKLVWLPH$QVKRRZDVZRUNLQJIRUDQ+3%XVLQHVVSDUWQHU
and we began collaborating on bringing them in to present at a chapter meeting. I then
PHW$QVKRRLQSHUVRQDW+3'LVFRYHUZDVLPSUHVVHGZLWKKLVVNLOODQGDELOLW\DQG
instantly knew that the audience would be in for a treat when he gave his presentation and
that his employer was lucky to have such a swell guy like him working for them. When
he mentioned that he was collaborating with Tarun for the next installment of the QTP
Unplugged series, I could hardly contain my excitement. After all, nothing excites a techie
more than a new deep dive into his or her favorite tool, right?

ew

6RIDVWIRUZDUGDQRWKHU\HDUDQGDJDLQ,ZDVDWWHQGLQJWKH+3'LVFRYHUFRQIHUHQFHZKHQ
I received word from Anshoo that Tarun was going to be at the conference. Anshoo offered
to facilitate an introduction, and of course, I jumped at the opportunity. It was a pleasure to
PHHWKLPDQGKHVWUXFNPHDVDWUXHDXWKRULW\LQWKLVHOG

Bo

ok

Pr

ev
i

So what does this have to do with the book youre about to read and reference for the
foreseeable future? When I met with Anshoo and Tarun, I realized that both of these men
are passionate about their trade, and that their passion for test automation doesnt stop at
the end of the business day. In talking to them, it quickly became apparent that they wanted
to share what theyve learned about this tool and its inner workings with their peers. After
several years and a diversion or two, theyve accomplished their goal by publishing this
ERRN,WLVP\EHOLHIWKDWWKLVERRNVKRXOGEHIRXQGLQHYHU\DXWRPDWLRQVKRSXWLOL]LQJ+3V
)XQFWLRQDO 7HVWLQJ VRIWZDUH 7KLV ERRN DQG LWV SUHGHFHVVRUV 4XLFN7HVW 3URIHVVLRQDO
8QSOXJJHG DQG $QG ,7KRXJKW , NQHZ 473  LV D JUHDW UHVRXUFH IRU WKRVH ZKR KDYH
experience writing or maintaining test automation frameworks in that it allows them to
respond to the challenges of test automation against modern software applications. After
reading this book, I hope you will come to the same conclusion. So enjoy; Im sure that
\RXOOQGWKLVWREHYHU\XVHIXOERWKQRZDQGLQWKHIXWXUH

Quality Assurance Engineer III, Gateway EDI


Vivit Board of Directors, Secretary
 &ROLQ : )ULHV KDV EHHQ ZRUNHG LQ WKH WHVW DXWRPDWLRQ VSDFH QHDUO\ KLV HQWLUH FDUHHU DQG KDV VSHQW WKH
PDMRULW\RIKLVWLPHLQWKHKHDOWKFDUHLQGXVWU\&ROLQKDVKDSSLO\XWLOL]HG473 DQGODWHU8)7 IRUWKHODVWYH
years and has extensive experience in writing, maintaining, and expanding upon Data-Driven, Keyword Driven
DQG+\EULGIUDPHZRUNV&ROLQLVDIOLDWHGZLWKWKH6W/RXLVFKDSWHURI4$, 4XDOLW\$VVXUDQFH,QVWLWXWH 
,,67 ,QWHUQDWLRQDO,QVWLWXWHIRU6RIWZDUH7HVWLQJ DQG9LYLW WKH,QGHSHQGHQW+36RIWZDUH8VHUV*URXS )RU
the past several years, Colin has been both a chapter leader and a member of the Board of Directors for Vivit.
In this capacity, he has strived to provide education, community, and advocacy for its members. In his spare
time, Colin enjoys running, cycling, researching test automation, and spending time with his wife and children

xii

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

Foreword
by Christopher J. Scharer

Pr

ev
i

ew

Before writing the foreword to this book, I read it in its entirety, and although its content
becomes increasingly more technical, each chapter builds on the previous one and
includes several real-life examples. This book is very well written and made me become
more interested the further I read. This book is focused toward conceptual knowledge of
QuickTest Pro (QTP) with a deep dive into Descriptive Programming (DP). It is a musthave for anyone who is testing using QTP and complements Taruns previous books,
4XLFN7HVW 3URIHVVLRQDO 8QSOXJJHG DQG $QG , WKRXJKW , NQHZ 473 :LWK VR PDQ\
companies moving to an Agile development/testing approach and application developers
working side-by-side with automation engineers, it is becoming more common and even
more important for an automation engineer to understand how to use DP.

Bo

ok

With all the recent game changers in the IT industry, such as Cloud computing, Big Data,
0RELOH7HVWLQJDQG:HE6HUYLFHV,ZRXOGGHQLWHO\UHFRPPHQGUHDGLQJWKLVERRNDQG
I really look forward to the next book that Tarun and Anshoo are working on currently,
which I believe is going to focus on testing methodologies and frameworks. I also hope to
be able to coordinate with them both to include a section on using Code Templates

Director (Vice President), Iowa, Nebraska & TQA-SIG Chapter Leader


Vivit Worldwide (http://www.vivit-worldwide.org)
* Christopher J. Scharer is an IT leader with over 15 years of technical experience in both the Software
Development and Software Testing Lifecycles and Application Lifecycle Management (ALM). Christopher
KDVEHHQLQYROYHGDWHYHU\VWDJHZLWKH[SHULHQFHLQ'DWD'ULYHQ.H\ZRUG'ULYHQDQG+\EULGPHWKRGRORJLHV
DQGKDVKHOSHGFRPSDQLHVDFKLHYHWHVWLQJVXFFHVVLQDZLGHYDULHW\RIEXVLQHVVDSSOLFDWLRQV %DQNLQJ)LQDQFH
+HDOWK,QVXUDQFH0RUWJDJHHWF &KULVWRSKHUVWDUWHGWKH9LYLW:RUOGZLGH/LQNHG,QJURXSDQGKDVKHOSHG
WR RUJDQL]H WKH 1HEUDVND9LYLW &KDSWHU DV ZHOO DV VHYHUDO9LYLW 0LGZHVW 5HJLRQDO (YHQWV  0RVW UHFHQWO\
&KULVWRSKHU ZDV HOHFWHG WR WKH SRVLWLRQ RI 9LFH 3UHVLGHQW RI 9LYLW :RUOGZLGH DQG ZRUNV FORVHO\ ZLWK +3
H[HFXWLYHVWRKHOSSURYLGHTXDOLW\WR+3VRIWZDUHXVHUV

http://KnowledgeInbox.com/store/

xiii

http://KnowledgeInbox.com/store/

Contents
Preface ............................................................................................ xxiii
Who this Book is For ............................................................................................... xxv
Questions or Feedback Related to the Book ............................................................ xxv
Source Code in the Book ......................................................................................... xxv

1. Introduction to Objects ..................................................................1


2. Object Repository .........................................................................11

Bo

ok

Pr

ev
i

ew

2EMHFW,GHQWLFDWLRQ6HWWLQJV .................................................................................... 15
Local Object Repository (LOR) ................................................................................ 16
Shared Object Repository (SOR)............................................................................... 18
$GGLQJ2EMHFWVWRWKH625 ....................................................................................... 20
$GGLQJDQ2EMHFWXVLQJ$GG2EMHFW%XWWRQ ...................................................... 20
'HQLQJWKH2EMHFW0DQXDOO\ ........................................................................... 20
$GGLQJ2EMHFWVWKURXJK2EMHFW6S\.................................................................. 22
1DYLJDWHDQG/HDUQ ................................................................................................... 23
Other Object-Related Features of OR........................................................................ 25
/RFDWLQJWKH2EMHFWLQ25................................................................................. 27
8SGDWLQJDQ2EMHFWIURPWKH$SSOLFDWLRQ ......................................................... 27
2EMHFW5HSRVLWRU\3DUDPHWHUV 253 ........................................................................ 28
,PSRUWLQJDQG([SRUWLQJ25IURP;0/ .................................................................. 32
8SGDWHIURP/RFDO2EMHFW5HSRVLWRU\...................................................................... 33
5HVROYLQJ&RQLFWVGXULQJWKH0HUJH ............................................................... 36
2EMHFW5HSRVLWRU\0HUJH7RRO................................................................................... 39
2EMHFW5HSRVLWRU\&RPSDULVRQ7RRO ......................................................................... 40
Local OR vs Shared OR ............................................................................................ 41
60$57,GHQWLFDWLRQ................................................................................................ 42
'LVDEOLQJ60$57,GHQWLFDWLRQ ....................................................................... 49
/RDGLQJ625DW5XQWLPH ......................................................................................... 52
/RDGLQJ625DW'HVLJQWLPH..................................................................................... 53

3. Descriptive Programming ............................................................55


Introduction................................................................................................................ 55

http://KnowledgeInbox.com/store/

473'HVFULSWLYH3URJUDPPLQJ8QSOXJJHG

http://KnowledgeInbox.com/store/

Bo

ok

Pr

ev
i

ew

2EMHFW,GHQWLFDWLRQ .................................................................................................. 55
Object Spy ......................................................................................................... 56
,PSOLFLWDQG([SOLFLW3URSHUWLHV ......................................................................... 58
:KHQWRXVH'HVFULSWLYH3URJUDPPLQJ ..................................................................... 59
'HVFULSWLYH3URJUDPPLQJ6\QWD[ .............................................................................. 60
8VLQJ'HVFULSWLRQ2EMHFWV................................................................................. 60
7KHPLFFODVV,GHQWLHU ...................................................................................... 63
8VLQJ'HVFULSWLRQ6WULQJV................................................................................. 63
(QXPHUDWLQJ&KLOG2EMHFWV......................................................................................... 64
&XVWRP&KHFN3RLQWV.................................................................................................. 66
&KHFN7HVW2EMHFW([LVWHQFH .................................................................................... 67
8VLQJ([LVW ....................................................................................................... 67
8VLQJ&KLOG2EMHFWV .......................................................................................... 68
&RQYHUWLQJDQ25EDVHG6FULSWWRD'3EDVHG6FULSW ............................................... 69
8VLQJD9%6FULSW'32EMHFW5HSRVLWRU\ ................................................................... 72
3UREOHPVZLWK2UGLQDO,GHQWLHUV.............................................................................. 73
:RUNLQJZLWK0XOWLSOH%URZVHUV .............................................................................. 75
%URZVHU,GHQWLFDWLRQ,VVXHV ..................................................................................... 77
&RPPRQ0LVWDNHVZKLOHXVLQJ'3 ........................................................................... 79
:ULWLQJ'3&RGHXVLQJ+70/6RXUFH&RGH ............................................................ 82
7HVW2EMHFW2YHUULGH .................................................................................................. 86
2EMHFW5HIHUHQFHV8QXVDEOHDIWHU1DYLJDWLRQ ........................................................... 86
$0\WKDERXW'3 ....................................................................................................... 87
2EMHFW&DVWLQJ ........................................................................................................... 88
3HUIRUPLQJDQ$FWLRQRQ0XOWLSOH2EMHFWV................................................................ 88
8VLQJ'HVFULSWLYH3URJUDPPLQJLQ6FULSWV ............................................................... 91
.H\ZRUGEDVHG'HVFULSWLYH3URJUDPPLQJ2EMHFW5HSRVLWRU\ ................................. 93
,PSOHPHQWLQJWKH.H\ZRUGEDVHG2EMHFW5HSRVLWRU\....................................... 94
,QVWDQWLDWLQJD7HVW2EMHFW ................................................................................. 96
8VLQJWKH2EMHFW5HSRVLWRU\ ............................................................................. 97
6WRULQJWKH2EMHFW5HSRVLWRU\ ........................................................................... 98
(QKDQFLQJWKH.H\ZRUGEDVHG2EMHFW5HSRVLWRU\ .................................................... 99
$OORZLQJ0XOWLSOH2EMHFW'HQLWLRQV ............................................................... 99

xvi

xvi

http://KnowledgeInbox.com/store/

Contents

http://KnowledgeInbox.com/store/

7HVW2EMHFW$OLDVHV .......................................................................................... 103


(QXPHUDWLRQRI&KLOG2EMHFWV ......................................................................... 104
8VLQJD+\EULG25 '3SOXVD5HJXODU25 ................................................... 106
&RQYHUWLQJ473625WR.H\ZRUGEDVHG'325 ........................................... 107

4. 9LVXDO5HODWLRQ,GHQWLHUV ..........................................................113
&UHDWLQJ9LVXDO5HODWLRQ,GHQWLHUVXVLQJ&RGH...................................................... 121

5. ChildObjects ................................................................................123

ew

8VLQJ,QLWRU5HIUHVK2EMHFWRQ'HULYHG2EMHFWV ..................................................... 129


'HULYHG2EMHFWVGRQ
W6XSSRUW5HJLVWHU8VHU)XQF ................................................... 130
'HULYHG2EMHFWVGRQ
W6XSSRUW2EMHFWVLQ)XUWKHU+LHUDUFK\.................................. 130
&KLOG2EMHFW5HWXUQV=HUR2EMHFWVIRU:HE(OHPHQWV .............................................. 131
'HWHFWLQJLIDQ2EMHFWKDVEHHQ'HULYHGXVLQJ&KLOG2EMHFWV ................................. 132

ev
i

6. HTML DOM ................................................................................133

Bo

ok

Pr

Introduction.............................................................................................................. 133
:KHQWR8VH+70/'20 ...................................................................................... 134
:KHQ1RWWR8VH+70/'20 ............................................................................... 136
+70/'202EMHFWV............................................................................................... 136
+70/1RGH .................................................................................................... 136
7KH'RFXPHQW2EMHFW...................................................................................... 136
+70/(OHPHQW2EMHFW .................................................................................... 137
+70/(OHPHQWV&ROOHFWLRQ ............................................................................ 137
Link and Button (Click)................................................................................... 138
7H[WER[ ............................................................................................................ 139
&RPER%R[RU/LVWER[ ................................................................................... 140
Checkbox ......................................................................................................... 140
Radio Group .................................................................................................... 141
+70/7DEOH .................................................................................................... 141
%LQGLQJWRDQ(OHPHQWXVLQJ+70/'20 ............................................................. 142
&RQYHUWLQJD'202EMHFWWRD4737HVW2EMHFW .................................................... 144
7UDYHUVLQJ+70/7UHH1RGHV................................................................................. 145
&KHFNLQJ$SSHDUDQFHXVLQJ6W\OH6KHHWV ................................................................ 147
&KHFNLQJ2EMHFW9LVLELOLW\ .............................................................................. 147

http://KnowledgeInbox.com/store/

xvii

473'HVFULSWLYH3URJUDPPLQJ8QSOXJJHG

http://KnowledgeInbox.com/store/

6HOHFWLQJD5DGLR%XWWRQE\7H[W ............................................................................ 150

7. 9LVXDO5HODWLRQ,GHQWLHUVXVLQJ+70/'20 ........................157
8. WebTables ....................................................................................167
:HE7DEOH,GHQWLFDWLRQLQ473 .............................................................................. 167
)LQGLQJD5RZZLWK6SHFLHG7H[W.......................................................................... 171
3HUIRUPLQJ2SHUDWLRQVRQ2EMHFWV,QVLGHWKH7DEOH ................................................ 172
)LQGLQJD5RZ&RQWDLQLQJ6SHFLF7H[W ............................................................... 173
&OLFNLQJ,QVLGHD:HE7DEOH ..................................................................................... 176
$V\QFKURQRXV7DEOH/RDGLQJ .................................................................................. 177
5HWULHYLQJWKH3DUHQW:HE7DEOHIURPDQ(OHPHQW .................................................. 178

ew

9. Testing Complex HTML Tables .................................................181


10. Localization Techniques and Design Patterns ........................197

Pr

ev
i

Introduction.............................................................................................................. 197
8VLQJD6HSDUDWH)XQFWLRQ/LEUDU\IRUHDFK/RFDOH ................................................ 203
8VLQJD6LPSOH/RFDOH&ROOHFWLRQ ........................................................................... 205
8VLQJD7DEOHEDVHG/RFDOH0DS............................................................................. 209
8VLQJD6LPSOH&ODVVEDVHG'HOLPLWHG&ROOHFWLRQ .................................................. 213
8VLQJD&ODVVEDVHG&HQWUDOL]HG'HOLPLWHG&ROOHFWLRQ ........................................... 217

ok

11. 2EMHFW,GHQWLFDWLRQXVLQJ;3DWK ...........................................223

Bo

Introduction.............................................................................................................. 223
$XWRPDWLF;3DWK;3DWK/HDUQHGDW5HFRUG7LPH................................................ 226
/HDUQLQJ;3DWKRQ)LUHIR[ ...................................................................................... 227
;3DWK([SUHVVLRQV:LOGFDUGV2SHUDWRUVDQG)XQFWLRQV ...................................... 229
Wildcards ......................................................................................................... 229
Operators ......................................................................................................... 230
;3DWK)XQFWLRQV .............................................................................................. 231
,PSOHPHQWLQJ;3DWKLQ473 ................................................................................... 232
6HOHFWLQJ1RGHV ............................................................................................... 232
6HOHFWLQJ3DUHQW1RGHVXVLQJ&KLOGUHQ ........................................................... 237
8VLQJ0DQXDO;3DWKZLWK2EMHFW5HSRVLWRU\ ......................................................... 238
;3DWK$[HV .............................................................................................................. 240
8QGHUVWDQGLQJ;3DWK$[HV.............................................................................. 241

xviii
xviii

http://KnowledgeInbox.com/store/

Contents

http://KnowledgeInbox.com/store/

;3DWK/LPLWDWLRQVDQG8QVXSSRUWHG;3DWKLQ473 ................................................ 249


;3DWKWRLGHQWLI\PXOWLSOHREMHFWV ................................................................... 249
)HWFKLQJWKH473JHQHUDWHG;3$7+ ...................................................................... 252

12. 2EMHFW,GHQWLFDWLRQXVLQJ&66...............................................253
7HVWLQJ&666HOHFWRUVZLWK)LUH3DWK ....................................................................... 258

13. ObjectRepositoryUtil ................................................................265


&RQYHUWLQJ%HWZHHQ765)LOHVDQG;0/)LOHV ...................................................... 266
&RQYHUWLQJ)LOHVIURP3UHYLRXV)RUPDWWRWKH/DWHVW)RUPDW ................................. 267
3ULQWLQJ1DPHVRIWKH:HE7DEOHVLQWKH25 ........................................................... 268
5HWULHYLQJDQ2EMHFW'LUHFWO\DQG0RGLI\LQJLWV3URSHUWLHV ................................... 269

ew

14. :RUNLQJZLWK473;0/25 ...................................................271

Pr

ev
i

)LQGLQJ5RRW2EMHFW1DPHV .................................................................................... 277


)LQGLQJ2EMHFW1RGHVXVLQJ1DPHV ........................................................................ 278
*HWWLQJ2EMHFW'HVFULSWLRQVIURP1DPHV................................................................ 278
*HWWLQJ2EMHFW'HVFULSWLRQXVLQJ3DWK .................................................................... 281
)LQGLQJ6WULQJ'HVFULSWLRQVIRU&KLOG2EMHFWV ....................................................... 282
*HWWLQJWKH2EMHFWIURPWKH'HVFULSWLRQ ................................................................. 283
8VLQJ253DWKWR6KRUWHQ&RGH ............................................................................... 283

ok

15. 7HVWLQJ:HE6HUYLFHV.................................................................287

Bo

Introduction.............................................................................................................. 287
$6LPSOH7HPSHUDWXUH&RQYHUVLRQ:HE6HUYLFH..................................................... 289
7HVWLQJ:HE6HUYLFHVXVLQJWKH:HE6HUYLFH$GGLQ .............................................. 293
Installation ....................................................................................................... 293
:HE6HUYLFHV7HVWLQJ:L]DUG .......................................................................... 297
9HULI\LQJ;0/5HVSRQVH9DOXHV .................................................................... 308
:HE6HUYLFH2EMHFW0HWKRGV ........................................................................... 309
7HVWLQJ:HE6HUYLFHV3URJUDPPDWLFDOO\ ................................................................. 311
;0/+7735HTXHVW ......................................................................................... 312
3DUVLQJ5HVSRQVHZLWK;0/8WLO..................................................................... 315
3DUVLQJ5HVSRQVHZLWK;0/'20 ................................................................. 316
7HVWLQJ62$35HTXHVWDQG5HVSRQVH...................................................................... 320

16. &RGLQJ6FULSWVLQ1(7.............................................................323
http://KnowledgeInbox.com/store/

xix

473'HVFULSWLYH3URJUDPPLQJ8QSOXJJHG

http://KnowledgeInbox.com/store/

473
V&RPPXQLFDWLRQZLWKDQ2XWRI3URFHVV&202EMHFW ................................. 323
(YHU\2EMHFWLQ473LVD&202EMHFW ........................................................... 325
4731(7&20%ULGJH .......................................................................................... 325
9%1(7&20%ULGJH ............................................................................................. 329
,QWHOOL6HQVHLQ1(7,'( ......................................................................................... 336

17. :HE([WHQVLELOLW\ ......................................................................339

ew

Introduction.............................................................................................................. 339
7KH&RPSDQ\/LVW$SSOLFDWLRQ................................................................................ 341
Installation ............................................................................................................... 344
5HFRUGLQJD7HVW:LWKRXW:HE$GGLQ([WHQVLELOLW\ ............................................... 347
'HYHORSLQJ7RRONLW6XSSRUW6HWZLWK([WHQVLELOLW\$FFHOHUDWRU ............................. 349
([WHQVLELOLW\LQ'HSWK .............................................................................................. 378
/LPLWDWLRQVDQG,VVXHV ............................................................................................. 390

ev
i

18. Creating Reserved Objects.......................................................393

Pr

Introduction.............................................................................................................. 393
+RZWR&UHDWH5HVHUYHG2EMHFWV ............................................................................. 394
&UHDWLQJDQ,FRQIRUWKH5HVHUYHG2EMHFW................................................................ 397

Appendix A - Approaches for Issue Resolution ............................401

Bo

ok

3UREOHP$SSOLFDWLRQFUDVKHVZKHQODXQFKHGZLWK473DOUHDG\RSHQ .............. 401


3UREOHP-DYDDSSOLFDWLRQFUDVKHVZKHQODXQFKHGDIWHULQVWDOOLQJ473V-DYD
add-in ....................................................................................................................... 402
3UREOHP473LGHQWLHV,(%URZVHUDVZLQGRZREMHFW ..................................... 403
3UREOHP473IDLOVWRLGHQWLI\WKHSDUHQWRIWKHWDUJHWREMHFW ............................ 404
3UREOHP473LVXQDEOHWRQGWKHWDUJHWREMHFW ................................................ 405
3UREOHP473QGVPXOWLSOHREMHFWVRIWKHVXSSOLHGGHVFULSWLRQ ...................... 406
3UREOHP*HQHUDO5XQ(UURURFFXUVZKLOHSHUIRUPLQJDQRSHUDWLRQ ............... 407
3UREOHP&KLOG2EMHFWVUHWXUQVREMHFWVHYHQZKHQWKHREMHFWVH[LVW ............... 408
3UREOHP473RQO\UHFRJQL]HV%URZVHUDQG3DJHREMHFWDIWHURSHQLQJRUFORVLQJ
of a popup opened by application ............................................................................ 408
3UREOHP,JHWGLIIHUHQWHUURUVZKHQXVLQJ0HUFXU\2EMHFW5HSRVLWRU\8WLO+RZ
FDQ,[WKHVHHUURUV" ............................................................................................... 409
3UREOHP+RZFDQ,NHHSD%URZVHURU:LQGRZDOZD\VRQ7RS".................... 410

Appendix B - Performance Benchmarks ......................................413


xx

xx

http://KnowledgeInbox.com/store/

Contents

http://KnowledgeInbox.com/store/

$SSHQGL[&;3DWKYV&66 ...........................................................423
$SSHQGL['1HVWLQJRI5HJLVWHU8VHU)XQF0HWKRGV..................427
$SSHQGL[((YDODQG([HFXWH .....................................................433

Bo

ok

Pr

ev
i

ew

$SSHQGL[)&URVV%URZVHU7HVWV ................................................437

http://KnowledgeInbox.com/store/

xxi

Preface

http://KnowledgeInbox.com/store/

Preface
Test Automation plays a crucial role in Software Development Lifecycle. With businesses
around the world pushing their IT teams to release software faster and sooner, Test
Automation has become an essential part of the testing lifecycle. Test Automation helps
perform redundant and repeatable tests against the application using an Automation tool.
QuickTest Professional (QTP), otherwise known as Functional Testing (FT) is one such
tool being used in the Test Automation domain.
QTP offers support for functional automation of various platforms:

ew

x Web
x VB

ev
i

x Windows
x ActiveX

Pr

x JAVA
x .NET

x Siebel

Bo

x SAP

ok

x WPF

x Peoplesoft
x Oracle

x PowerBuilder
x Stringray
x Terminal Emulators
x VisualAge Smalltalk
473 VXSSRUWV WKHVH WHFKQRORJLHV XVLQJ DQ H[WUHPHO\ ZHOO ODLGRXW 2EMHFW ,GHQWLFDWLRQ
PHFKDQLVPDUFKLWHFWXUHSURYLGLQJXVHUVZLWKDVHWRISUHGHQHGREMHFWW\SHVDQGSURSHUWLHV

http://KnowledgeInbox.com/store/

xxiii

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

IRUWKHJLYHQWHFKQRORJ\DQGLWVFRUUHVSRQGLQJREMHFWV,GHQWLFDWLRQDJDLQVWWHVWREMHFWV
is performed by storing a set of known properties directly related to the type of object. For
H[DPSOHWRLGHQWLI\DWH[WER[LQDZHESDJH473GHQHVWKHREMHFWW\SHDV:HE(GLWDQG
some of the common properties to identify such an object are html tag, type, id and name.

ew

7KH473LGHQWLFDWLRQPHFKDQLVPZRUNVSHUIHFWO\DVORQJDVWKHDSSOLFDWLRQXQGHUWHVW
exposes test objects in such a way that its add-ins identify the interface presented by
the underlying technology. If the relevant add-in is not associated with the test or if the
ZD\VWHVWREMHFWVDUHH[SRVHGGRQRWPHHWWKHFULWHULDIRU2EMHFW,GHQWLFDWLRQ473IDLOV
WR LGHQWLI\ REMHFWV FRUUHFWO\$W WLPHV XQVXSSRUWHG REMHFWV DUH GHQHG XVLQJ D JHQHULF
WinObject. In such cases, certain workarounds must be implemented to enable QTP to
accurately identify objects.

ev
i

(YHQ D VPDOO REMHFW LGHQWLFDWLRQ LVVXH FDQ EHFRPH D PDMRU SUREOHP ,W LV WKHUHIRUH RI
the utmost importance to understand how to work around the features of the tool and to
consider the options available to overcome the issue.

Bo

ok

Pr

7KHSULPDU\IRFXVRIWKLVERRNLV2EMHFW,GHQWLFDWLRQZLWK4737KLVERRNSODFHVJUHDW
emphasis upon how to tackle the challenges one faces when implementing a real-life project.
To illustrate, consider a page which presents a textbox generated at run-time and which has
a dynamic NAME property; the propertys value changes during each run-session. This can
SRVHDJUHDWFKDOOHQJHLQLGHQWLFDWLRQDVWKHUHPD\EHQRXQLTXHSURSHUW\ZLWKZKLFKWR
LGHQWLI\WKHREMHFWRUWKHDYDLODEOHSURSHUWLHVPD\QRWEHVXIFLHQWIRUDUREXVWGHVFULSWLRQ
Hence it is important to be able to understand the implementation and also to come up
with a robust description. This book will walk you through such real-life scenarios and
LPSOHPHQWDWLRQLVVXHVZKLOHSURYLGLQJVHYHUDOUHVROXWLRQWHFKQLTXHV
The book also covers Descriptive Programming and Object Repository concepts in depth
and walks the reader through some of the really innovative ways in which these can be used
IRU2EMHFW,GHQWLFDWLRQDQG7HVW,PSOHPHQWDWLRQ
This book is written by two seasoned experts from the QTP community, Tarun Lalwani,
who has published several other books (including the renowned QuickTest Professional
Unplugged) on QTP and is the founder of the website KnowledgeInbox, and Anshoo Arora,
the founder of Relevant Codes, a website with focus on Test Automation. Both authors

xxiv

http://KnowledgeInbox.com/store/

Preface

http://KnowledgeInbox.com/store/

have worked for different international clients and have extensive real-time experience in
Test Automation.

Who this Book is For


We recommend this book for those who use HP QTP (FT) or Business Process Testing
(BPT). The book assumes that the reader has basic knowledge of both QTP and VBScript.

Questions or Feedback Related to the Book


)HHGEDFNRUTXHVWLRQVUHODWHGWRWKLVERRNFDQEHVHQWWKURXJKDQ\RIWKHEHORZOLVWHGPRGH

ew

feedback@knowledgeinbox.com
www.KnowledgeInbox.com/contact-us/
ZZZIDFHERRNFRPTWSGSXQSOXJJHGERRN

ev
i

Email:
Website:
Facebook:

Source Code in the Book

Pr

The source codes used in the book can be downloaded from: www.KnowledgeInbox.com/
demos/QTPDPUnplugged_SourceCodes.zip

ok

Ordering this Book

India: You can place an order online at www.KnowledgeInbox.com/store/

Bo

Other countries: Please check online at www.KnowledgeInbox.com/books/


For bulk orders, contact us at orders@KnowledgeInbox.com

http://KnowledgeInbox.com/store/

xxv

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

Introduction to Objects

Bo

ok

Believe it or not, our lives are surrounded by objects. From small to large, we encounter
a huge variety of objects of various types on a daily basis. The neurons in our brain use
information from our different senses, such as vision, smell, hearing and touch, to help us
identify an object. In fact, the human brain works pretty seamlessly in performing this task.
But for a normal computer program to match that power is not easy.
,QRUGHUWRDXWRPDWHDSSOLFDWLRQVRQHRIWKHPRVWFUXFLDOHOHPHQWVLV2EMHFW,GHQWLFDWLRQ
This is one of the tough challenges that Automation Engineers face around the world with
various automation tools; any application can pose a challenge different in nature to any
other application.
In object-driven automation, events against objects can only be executed if the software
LV DEOH WR FRUUHFWO\ LGHQWLI\ WKRVH REMHFWV ,I WKH VRIWZDUH IDLOV LQ 2EMHFW ,GHQWLFDWLRQ
WKHDSSOLFDWLRQEHFRPHVLPSRVVLEOHWRDXWRPDWH2EMHFW,GHQWLFDWLRQLVWKHUHIRUHDFRUH
FRQFHSWLQ7HVW$XWRPDWLRQ0RUHRYHUWKHZD\DQREMHFWLVLGHQWLHGPRVWO\GHSHQGVRQ
the technology that is used to implement the object. Consider the Windows Run window
as shown in the image below:

http://KnowledgeInbox.com/store/

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

Figure 1.1 Windows Run command window

Bo

ok

Pr

ev
i

ew

Our aim is to click the Cancel button. When we spy the Cancel button using QTPs Object
6S\LWLGHQWLHVDKLHUDUFK\RIREMHFWVZLWKWKH5XQZLQGRZDVWKHURRWREMHFWDQGWKH
Cancel button as the child of the Run window.

Figure 1.2 Object Spy - Cancel Button

http://KnowledgeInbox.com/store/

1 Introduction to Objects

http://KnowledgeInbox.com/store/

QTP is able to identify the Cancel button we wanted to click. Now we can add this object
to the Object Repository and perform the click using the following code:
Dialog("Run").WinButton("Cancel").Click

Bo

ok

Pr

ev
i

ew

This works because QTP internally knows how to recognize a native Windows object. QTP
does this through the use of the corresponding add-ins. Every technology is represented
as an individual add-in. When QTP is launched, it provides a list from which to select the
relevant add-ins through the Add-in Manager.

Figure 1.3 QTP Startup Add-in Manager

http://KnowledgeInbox.com/store/

QTP Descriptive Programming Unplugged

NOTE:

http://KnowledgeInbox.com/store/

For Windows native objects, no special add-in is

required.

Pr

ev
i

ew

To demonstrate how the technology behind the GUI makes a difference, we have created a
Java GUI for the same Run window we used earlier in this chapter:

Figure 1.4 Dummy Java based Run command window

ok

Now if we Spy the same Cancel button again using QTPs Object Spy, we will notice one
crucial difference as shown in Figure 1.5 Object Spy - Java Run Command window.

Bo

QTP is only able to identify the top level window and nothing inside the window. This
PDNHVFOLFNLQJRQWKH&DQFHOEXWWRQGLIFXOWDVZHFDQQRWLGHQWLI\LWDVDXQLTXHREMHFW
The reason this is because the Java add-in is not loaded during startup. There may be
circumstances when QTP may fail regardless of the add-in selected. In such a case, we
PXVWLPSOHPHQWZRUNDURXQGVVXFKDVQGLQJWKHORFDWLRQRIWKH&DQFHOEXWWRQDQGXVLQJ
LWVFRRUGLQDWHVWRUHDPRXVHFOLFNHYHQW1RZOHWXVORDGWKH-DYDDGGLQGXULQJ473
startup as shown in Figure 1.6 Loading Java Add-in at startup
When we use the Object Spy again on the Run window made in Java, we will be able to
identify the objects inside the Run window as shown in Figure 1.7 Object Spy for Java
Run window after loading Java Add-in

http://KnowledgeInbox.com/store/

1 Introduction to Objects

Bo

ok

Pr

ev
i

ew

http://KnowledgeInbox.com/store/

Figure 1.5 Object Spy - Java Run Command window

http://KnowledgeInbox.com/store/

QTP Descriptive Programming Unplugged

Bo

ok

Pr

ev
i

ew

http://KnowledgeInbox.com/store/

Figure 1.6 Loading Java Add-in at startup

QTP Add-ins for Object Identification


Very little has ever been written about how QTP add-ins work internally and HP has not
openly provided documentation on the architecture of add-ins. Here we will throw some
light on the topic to the best of our understanding.
No two add-ins are the same in QTP; each add-in operates in a different manner. For
example, the SAP add-in uses the SAP GUI Scripting API provided by SAP internally, so
any bug in the SAP GUI Scripting API gets propagated to QTP.

http://KnowledgeInbox.com/store/

1 Introduction to Objects

Bo

ok

Pr

ev
i

ew

http://KnowledgeInbox.com/store/

Figure 1.7 Object Spy for Java Run window after loading Java Add-in

One such example is the max length, where the SAP GUI scripting engine returns the max
length of a control as the length of text present in the control. This causes QTP to fail when
performing a set operation if the text being set is bigger than the text already present. The
SAP OSS note 1460861 - Scripting: MaxLength property returns wrong value describes
the issue.
Similarly, the Siebel add-in uses the SIEBEL Automation API for interacting with the

http://KnowledgeInbox.com/store/

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

Siebel High Interactivity client.


2WKHUDGGLQVVXFKDV$FWLYH;:HE1(7DQG9%SODFHKRRNVLQWRWKHUHTXLUHGSURFHVVHV
Lets launch QTP with the ActiveX and Web add-ins selected. Using Sysinternals Process
([SORUHUZHFDQVHHWKDW,(KDVFHUWDLQ'//OHVORDGHGLQLWVPHPRU\DQGWKDWWKHVHOHV
are related to QuickTest Professional (QTP), as shown in Figure 1.8.

ew

Acx_trap.dll, Acx_srv.dll, AcxSettings.dll and AcxOutputChannel.dll are some of the


DLLs that QTP loads into the IE process to work on the ActiveX objects loaded by IE.
Loading these DLLs into the process actually alters the state of the system being tested and
means that we are testing our application with the help of external DLLs loaded into IE
which may not be present when an actual user would be using the same application. These
DLLs can, in rare instances, cause the Application Under Test (AUT) to crash or have some
undesired behavior such as poor performance.

ev
i

Timing for Launching the Application

Pr

You may have already heard that it is necessary to launch QTP before starting your
DSSOLFDWLRQ7KHUHDVRQEHKLQGWKDWUHTXLUHPHQWLVWKDWZKHQ473LVODXQFKHGLWSODFHV
FHUWDLQ KRRNV LQ WKH V\VWHP HDFK RI ZKLFK  LV WDUJHWHG IRU D VSHFLF DSSOLFDWLRQ ,I WKH
application is launched before QTP, then these hooks will not be present in the application
and QTP will not be able to communicate with the application in the way intended.

ok

However, this is not true for all applications or add-ins. Consider a few of the known
exceptions:

Bo

 The SIEBEL add-in uses SIEBEL Automation API, so if a SIEBEL application is


launched before QTP, QTP will still be able to identify the Siebel objects. This is
because even though Siebel runs inside a web Browser, QTP will not identify the
Browser properly but rather identify it as a normal native window.
 Any Windows application that uses just native Windows objects (Window,
Dialog, WinEdit etc.) can be launched before QTP itself. QTP uses native system
APIs (Let FindWindow, FindWindowEx etc.) to identify these objects and is
therefore not dependent on the prior launching of QTP. Java applications also
FDQEHLGHQWLHGHYHQLIWKHDSSOLFDWLRQLVODXQFKHGEHIRUH473473XVHVWKUHH
Windows environment variables (_JAVA_OPTIONS, IBM_JAVA_OPTIONS and
JAVA_TOOL_OPTIONS) to inject its JVM hook and the application is hooked
irrespective of whether QTP is launched or not.

http://KnowledgeInbox.com/store/

1 Introduction to Objects

Bo

ok

Pr

ev
i

ew

http://KnowledgeInbox.com/store/

Figure 1.8 - DLL's loaded into Internet Explorer with QTP open

 The SAP add-in uses SAP Scripting GUI and therefore a SAP GUI application will
VWLOOEHLGHQWLHGFRUUHFWO\HYHQLIODXQFKHGEHIRUH473

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

Pr

ev
i

Object Repository

ew

Bo

ok

2EMHFW,GHQWLFDWLRQLVWKHNH\FRQFHSWWRXQGHUVWDQGLQJWKHUHVWRIWKLVERRN(YHU\WKLQJ
ZHZLOOUHDGLQWKLVERRNLVFRQFHUQHGZLWK2EMHFW,GHQWLFDWLRQXVLQJWHFKQLTXHVVXFKDV
2EMHFW5HSRVLWRU\ 25 DQG'HVFULSWLYH3URJUDPPLQJ '3 %XWEHIRUHZHGLYHLQWRWKH
GHWDLOVRI25DQG'3LWVLPSRUWDQWWRXQGHUVWDQGWKHFRQFHSWRILGHQWLFDWLRQDQGKRZ
H[DFWO\LWZRUNV
:KHQZHUHFRUGDVFULSWLQ473LWPRQLWRUVDOOHYHQWVWKDWKDSSHQLQWKHV\VWHP%DVHG
RQ473VFRQJXUDWLRQDQGWKHDGGLQVORDGHGLQLWVPHPRU\VRPHRIWKHVHHYHQWVDUH
FDSWXUHG LQ WKH WHVW VFULSW 1RW DOO HYHQWV JHW UHFRUGHG HJ PRXVH PRYHPHQWV DUH QRW
FDSWXUHG LQ FRQWH[W VHQVLWLYH DQG ORZOHYHO UHFRUGLQJ:KHQ 473 UHFRUGV DQ HYHQW WKH
IROORZLQJSURFHVVRFFXUV
 $GGLQJRIREMHFWVWR25 ZLWKDORJLFDOQDPH ZKLFKLVQHFHVVDU\IRUUHSOD\
 $GGLQJRILGHQWLFDWLRQSURSHUWLHVWRREMHFWVLQWKH25VR473FDQLGHQWLI\WKH
REMHFWGXULQJUHSOD\
 *HQHUDWLQJDFRGHVWDWHPHQW V LQ473ZKLFKFRQVLVWVRI2EMHFW$FWLRQDQG'DWD
)RUH[DPSOHLQWKHEHORZVWDWHPHQW

http://KnowledgeInbox.com/store/

11

3 Descriptive Programming

http://KnowledgeInbox.com/store/

dpBtnLogin = "name:=Login,index:=0"

'RLQJVRZLOODVN473WRLGHQWLI\DQREMHFWZKLFKKDVQDPHDV/RJLQLQGH[ 7KLVLVD
common mistake that is often made by novice users of DP. Instead of using a string based
DP, we need to use object-based DP. We can update the library as follows:
Set dpBtnLogin = Description.Create
dpBtnLogin("name").value = "Login"
dpBtnLogin("index").value = 0

ew

The above uses a hybrid of string-based and object-based DP. Using string-based DP means
using less memory and shorter code, while using object-based DP means higher memory
and lengthier code but less maintenance in scripts. This is because it allows adding multiple
SURSHUWLHVWRWKHGHVFULSWLRQDQGGRHVQWUHTXLUHDQ\PRGLFDWLRQWRWKHVFULSW

Pr

ev
i

7KLV DSSURDFK ZRUNV ZHOO ZKHQ WKH QXPEHUV RI REMHFWV LQ WKH DSSOLFDWLRQ LV VPDOO %XW
ZKHQWKHQXPEHURIREMHFWVLQFUHDVHVWKHOLEUDU\VL]HDOVRLQFUHDVHVPDNLQJLWGLIFXOWWR
PDLQWDLQDQGORRNXSREMHFWV$GGLWLRQDOO\EHFDXVHDOOREMHFWGHQLWLRQVDUHLQWKHVDPH
OLEUDU\WKHOLEUDU\FDQWEHXSGDWHGE\PXOWLSOHXVHUVDWWKHVDPHWLPH7RRYHUFRPHWKLV
we will create a Keyword-based Object Repository.

ok

Keyword-based Descriptive Programming


Object Repository

Bo

This section describes how we can create a Keyword-driven Object Repository of


programmatic descriptions. The following objects and properties are required for a custom
object to implement this solution:
 1DPHRU.H\ZRUG'HQHVDXQLTXHQDPHWRLGHQWLI\HDFKREMHFW7KLVLVVLPLODU
WR GHQLQJ D YDULDEOH LQ \RXU 9%6FULSW FRGH WKHUHIRUH VSDFHV DQG DQ\ VSHFLDO
FKDUDFWHUVWKDWDUHDJDLQVW9%6FULSWUXOHVDUHQRWSHUPLWWHGKHUH
 7\SH'HQHVWKH7HVW2EMHFWFODVV PLFFODVV RIWKHWDUJHWREMHFW 3DJH:LQGRZ
WebEdit etc.).
 3DUHQW'HQHVWKHNH\ZRUGXVHGIRUWKHSDUHQWREMHFW'HQLQJWKHNH\ZRUGIRU
the parent object helps us in the following ways:
R It becomes possible to fetch all objects associated with any given parent.

http://KnowledgeInbox.com/store/

93

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

R It helps to obtain complete details about an object by simply using its


associated keyword without the need to provide any additional information
in code. This helps ensure the code remains generic.
 ,GHQWLHU V 'HQHVWKHWHVWREMHFWVSURSHUWLHVXVHGWRLGHQWLI\WKHWHVWREMHFW

ew

/HWVVHHKRZRXUVDPSOH2EMHFW5HSRVLWRU\ZRXOGORRNOLNH

ev
i

Figure 3.7 Sample Keyword-based Object Repository

NOTE: In this example, we have used only 2 columns for

ok

Pr

&@AJPEANO>QPUKQ?=J=@@=JUJQI>ANKB?KHQIJOPK>QEH@
unique descriptions. However, we recommend a maximum
KB  E@AJPEANO &@A=HHU OLA=GEJC  PDA JQI>AN KB E@AJPEANO
should be 2-3.

Bo

Next, we will explore a few different aspects of implementing this approach of building a
custom Object Repository.

Implementing the Keyword based Object Repository


As we saw in the Figure 3.7, we must store some information about each object: Name,
7\SH3DUHQW,GHQWLHUDQG,GHQWLHU7RIDFLOLWDWHWKLVVWRUDJHRILQIRUPDWLRQZHZLOO
create a new class called TestObject:
'Class to store object information
Class TestObject
Dim Keyword
Dim ObjectType
Dim Parent


94

http://KnowledgeInbox.com/store/

3 Descriptive Programming

http://KnowledgeInbox.com/store/


End Class

To maintain the object repository we will use a Dictionary object to store the information
about each test object. Keys of the Dictionary will store the keywords whereas the items
will store the target test objects as shown here:
'Create dictionary for storing objects in object repository
Dim ObjectRepository
Set ObjectRepository = CreateObject("Scripting.Dictionary")

Pr

ev
i

ew

Public Function AddObjectToOR(ByVal sKeyword, ByVal sObjectType, ByVal


sParent, ByVal sID1, ByVal sID2)
Set oTestObject = New TestObject
With oTestObject
.Keyword = sKeyword
.ObjectType = sObjectType
.Parent = sParent
  
  
End With

Bo

ok

'Create an object with sKeyword


'Overwrite if the object already exists
Set ObjectRepository(sKeyword) = oTestObject
End Function

In order to make our object repository case-insensitive, we simply add the next line of code
after creating the Dictionary:
'Set text compare mode for keyword for object to be incase-sensitive
ObjectRepository.CompareMode = vbTextCompare

NOTE:

AddObjectToOR does not check whether the


object already exists in the Object Repository. It creates and
stores a new object if the object does not exist and overwrite
PDA K>FA?P @AJEPEKJ EJ ?=OA PDA K>FA?P =HNA=@U ATEOPO 1DEO
allows updating the OR at Run-time using a single function
call. However, this behavior can be changed by modifying the
functions code.

http://KnowledgeInbox.com/store/

95

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

3EOQ=H/AH=PEKJ&@AJPEANO

Bo

ok

473  LQWURGXFHG D QHZ W\SH RI 2EMHFW ,GHQWLFDWLRQ PHFKDQLVP NQRZQ DV 9LVXDO
5HODWLRQ,GHQWLHUV 95, $VWKHQDPHVXJJHVWVWKLVPHFKDQLVPXVHVYLVXDOUHODWLRQVKLSV
EHWZHHQ WZR RU PRUH REMHFWV WR XQLTXHO\ LGHQWLI\ WKH WDUJHW REMHFW %HIRUH VHHLQJ KRZ
WKLVLGHQWLFDWLRQZRUNVZHZLOOUVWVHHDVLWXDWLRQZKHUHWKLVIHDWXUHPD\EHUHTXLUHG
&RQVLGHUWKHH[DPSOHEHORZ

Figure 4.1 VRI Demo Page

http://KnowledgeInbox.com/store/

113

http://KnowledgeInbox.com/store/

ok

Pr

ev
i

ew

ChildObjects

Bo

We looked at the ChildObjects method earlier in the Descriptive Programming chapter.


This chapter discusses ChildObjects in detail and highlights the key concepts that users
should be aware of.
Let's look again at how we use ChildObjects.
Dim oDesc
Set oDesc = Description.Create
oDesc("micclass").value = "WebEdit"
oDesc("name").value = "txt_.*"
'Find all the childObjects
Set allTextBox = Browser("B").Page("P").ChildObjects(oDesc)
Dim i
For i = 0 to allTextBox.Count - 1

http://KnowledgeInbox.com/store/

123

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

HTML DOM

ok

Introduction

Bo

The HTML DOM is a Document Object Model for representing HTML documents. DOM
LVD:&VWDQGDUGZKLFKLVSODWIRUPDQGODQJXDJHLQGHSHQGHQWDQGGHQHVDVWDQGDUG
set of objects in a tree structure of elements. It provides a standard approach to access and
manipulate HTML documents. All elements, along with their text and attributes can be
accessed and manipulated through the DOM tree.
The QTP Page objects .Object property provides access to the HTML DOM:
'Get the DOM document object
Set oDocument = Browser("Browser").Page("Page").Object

http://KnowledgeInbox.com/store/

133

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

3EOQ=H/AH=PEKJ&@AJPEANOQOEJC%1*)
!,*

Bo

ok

A limitation of 9LVXDO5HODWLRQDO,GHQWLHUVLVWKDWLWFDQQRWEHXVHGZLWKSURJUDPPDWLF
GHVFULSWLRQV 1RW DOO DXWRPDWLRQ IUDPHZRUNV XVH WKH 2EMHFW 5HSRVLWRU\ VR PDNLQJ XVH
RI 9LVXDO 5HODWLRQ ,GHQWLHUV 95,  IRU 2EMHFW ,GHQWLFDWLRQ LQ D :HE HQYLURQPHQW 
LV QRW SRVVLEOH RXWRIWKHER[7KHUH LV KRZHYHU D ZRUNDURXQG XVLQJ +70/ '20 DV
GHPRQVWUDWHGLQWKLVVHFWLRQ
:HXVHWKHIROORZLQJ'20SURSHUWLHVWRWUDYHUVHQRGHV
!,*-NKLANPU
childNodes
UVW&KLOG
ODVW&KLOG
QH[W6LEOLQJ
SDUHQW1RGH

!AO?NELPEKJ
5HWULHYHV D FROOHFWLRQ RI +70/ HOHPHQWV DQG 7H[W1RGH REMHFWV
WKDWDUHLPPHGLDWHGHVFHQGDQWVRIWKHWDUJHW
5HWULHYHVWKHUHIHUHQFHWRWKHUVWFKLOGLQWKHFKLOG1RGHVFROOHFWLRQ
5HWULHYHVWKHUHIHUHQFHWRWKHODVWFKLOGLQWKHFKLOG1RGHVFROOHFWLRQ
5HWULHYHVWKHUHIHUHQFHWRWKHIROORZLQJQRGHRIWKHWDUJHWZKLFKLV
DOVRWKHQH[WFKLOGRIWKHVDPHSDUHQWDVWKHWDUJHW
5HWULHYHVWKHUHIHUHQFHWRWKHSDUHQWREMHFWRIWKHWDUJHW

http://KnowledgeInbox.com/store/

157

http://KnowledgeInbox.com/store/

ok

Pr

ev
i

ew

WebTables

Bo

A huge amount of testing today is done on Web/HTML. A TABLE tag in HTML can be
used to present data or perform layouts on the webpage. This chapter will focus on some of
the key tasks that need to be performed when dealing with WebTables. But before we start
ZLWKWKHVHWDVNVZHZDQWWRGLVFXVV:HE7DEOHLGHQWLFDWLRQ

4A>1=>HA&@AJPE?=PEKJEJ.1:KHQZHDGGD:HE7DEOHREMHFWWRWKH2EMHFW5HSRVLWRU\ 25 LWLGHQWLHVWKHREMHFW
XVLQJWKH,QGH[2UGLQDO,GHQWLHUDVVKRZQLQWKHLPDJHEHORZ

http://KnowledgeInbox.com/store/

167

8 WebTables

http://KnowledgeInbox.com/store/

#EJ@EJC=/KS KJP=EJEJC0LA?E?1ATP

ok

Pr

ev
i

ew

We saw earlier how the GetRowWithCellText method provides us with a way to search for
VSHFLFWH[WSUHVHQWLQWKHFHOO%XWWKHUHLVQRPHWKRGZKLFKDOORZVXVWRVHDUFKDURZZLWK
WH[WLQPXOWLSOHFROXPQVRIWKHWDEOH&RQVLGHUWKHIROORZLQJWDEOH

Figure 8.3'HPRZHESDJH

Bo

If we want to search for the second edition of QuickTest Professional Unplugged, we


KDYHWRXVHDORRSZLWK*HW5RZ&HOO7H[WDQGQGWKHURZDVVKRZQEHORZ
Dim bExit, bFound, iRow, iStartRow
bExit = False

bFound = False
iStartRow = 1
Do
iRow = Browser("Browser").Page("Page").WebTable("Book").
GetRowWithCellText("QuickTest Professional Unplugged",1, iStartRow)
If iRow = -1 Then
bFound = False
bExit = True
Else
'Next time we will search for one row further

http://KnowledgeInbox.com/store/

173

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

Testing Complex HTML Tables

Bo

ok

Previously in web-design, UI Designers used the TABLE tags to create a tabular look and
feel. This TABLE tag implementation makes it easier for Automation Engineers to process
data and perform actions on objects inside the table. Consider the following table:

Figure 9.1 Demo web page

The HTML implementation is as follows:


<html>

http://KnowledgeInbox.com/store/

181

http://KnowledgeInbox.com/store/

10

Pr

ev
i

ew

Localization Techniques and Design


Patterns

ok

Introduction

Bo

$V DSSOLFDWLRQV EHFRPH JOREDO DGDSWLQJ WKHP WR VSHFLF FXOWXUHV RU ORFDOHV EHFRPHV D
PDVVLYHWDVN<RXPD\KDYHYLVLWHGZHEVLWHVWKDWSURYLGHVLWVXVHUV WRFRQYHUWWKHEDVH
ORFDO WH[WWRWKHWH[WRIWKHORFDOHFKRVHQ)RUH[SODQDWLRQDQGVLPSOLFLW\WKLVERRNXVHVD
[HG+70/VFKHPHIRU(QJOLVKDQG6SDQLVKIRUWKHGHPRQVWUDWLRQRIWHFKQLTXHVWKDWFDQ
VLPSOLI\ORFDOL]DWLRQWHVWLQJ
%HORZLVDOLVWRIVRPHFRPPRQO\XVHGORFDOHV
Locale Description
$IULNDDQV
$UDELF8QLWHG$UDE(PLUDWHV
&KLQHVH&KLQD
&KLQHVH+RQJ.RQJ

http://KnowledgeInbox.com/store/

LCID (Locale ID)


af
DUDH
]KFQ
]KKN

197

/RFDOL]DWLRQ7HFKQLTXHVDQG'HVLJQ3DWWHUQV
http://KnowledgeInbox.com/store/


Dim path

LoadFunctionLibrary path
End Sub

7KHIROORZLQJFRGHZLOOEHXVHGWRORDGWKHORJLQYEVOLEUDU\ZLWK(QJOLVKORFDOH
LoadLocaleLib "login.vbs", "en-us" 'English

7KHFRGHEHORZZLOOEHXVHGWRORDGWKHORJLQYEVOLEUDU\ZLWK6SDQLVKORFDOH

ew

LoadLocaleLib "login.vbs", "es-es" 'Spanish

7KHDERYHORDGLQJPHFKDQLVPFDQHLWKHUEHVWRUHGLQDWHVWRULQDQDVVRFLDWHGIXQFWLRQ
OLEUDU\ UHFRPPHQGHG 

Advantages

Bo

 (DV\WRXVH

ok

Pr

ev
i

(YHQWKRXJKWKLVWHFKQLTXHLVYHU\HDV\WRXVHLWKDVTXLWHDKLJKPDLQWHQDQFHRYHUKHDG
EHFDXVHWKHVDPHFRS\RIWKHOLEUDU\ ZLWKGLIIHUHQWORFDOHV H[LVWVLQGLIIHUHQWORFDWLRQV
&KDQJHVPDGHWRWKHRZRIWKHDSSOLFDWLRQZLOOUHVXOWLQGHYHORSHUVLPSOHPHQWLQJWKH
XSGDWH LQ PXOWLSOH SODFHV +RZHYHU D ELJ PDLQWHQDQFH RYHUKHDG FDQ EH WUDGHG IRU D
VLWXDWLRQZKHUHFKDQJHVLQORFDOHDOVRUHVXOWVLQWKHFKDQJHRIRZRURYHUDOO8,GHVLJQ,Q
RWKHUZRUGVWKLVDSSURDFKPDNHVLWHDVLHUWRDFFRPRGDWHIRUVLWXDWLRQVZKHUHFRGHORJLF
FKDQJHVIURPRQHORFDWHWRDQRWKHU

 3URYLGHVH[LELOLW\LQVLWXDWLRQVZKHUHRZGLIIHUVIURPORFDOHWRORFDOH
'LVDGYDQWDJHV

 3RRUPDLQWHQDQFHFKDQJHVPDGHWRRQHOLEUDU\PXVWEHFRSLHGWRDOORWKHUOLEUDULHV
 &UHDWLQJOLEUDULHVIRUHDFKORFDOHFDQEHDWLPHFRQVXPLQJSURFHVV

Using a Simple Locale Collection


$Q H[WHQVLEOH 6FULSWLQJ'LFWLRQDU\ LV D YHU\ H[LEOH DQG H[SDQGDEOH DSSURDFK ZKLFK
FDQEHFUHDWHGXVLQJSURFHGXUDOPHWKRGVRUREMHFWRULHQWHG7KHFUX[RIWKLVDSSURDFKLV

http://KnowledgeInbox.com/store/

205

/RFDOL]DWLRQ7HFKQLTXHVDQG'HVLJQ3DWWHUQV
http://KnowledgeInbox.com/store/

IXQFWLRQDOLW\
'Test: Action1

main_Page.Run

main_Page.Run

8QOLNHWKHSUHYLRXVDSSURDFKHVWKLVPHWKRGGRHVQRWXVHDJOREDOYDULDEOHWRGHQHWKH
ORFDOHWRWHVWDJDLQVW7KLVDSSURDFKSURYLGHVWKHH[LELOLW\WRGHQHWKHORFDOHDWDQ\JLYHQ
WLPHXVLQJ/RFDOH'HQH

Pr

ev
i

ew

(YHQ WKRXJK WKLV DSSURDFK LV YHU\ PXFK OLNH WKH SUHYLRXV RQH ZLWK WKH GDWDVRXUFH LW
RPLWVWKHQHHGWRFUHDWHDQH[WHUQDOVRXUFHWRGHSHQGXSRQIHHGLQJWKHFRUUHFWGHVFULSWLRQV
7KLVPD\EHDGYDQWDJHRXVLQHQYLURQPHQWVZKHUHFUHDWLQJDVWDQGDORQHGDWDVRXUFHGRHV
QRWZRUNZHOO VHHWKH'LVDGYDQWDJHVVHFWLRQRIWKHSUHYLRXVDSSURDFK8VLQJD7DEOH
EDVHG/RFDOH0DS $OOSURSHUWLHVDUHVWRUHGZLWKLQWKHVDPH&ODVVDQGWKLVHQDEOHVD
VLQJOHORFDWLRQRIPDLQWHQDQFHIRUFKDQJHVLQRZDVZHOODVFKDQJHVLQORFDOHYHUELDJH
,QDGGLWLRQWKLVDSSURDFKDOVRHQDEOHVWHVWLQJPXOWLSOHORFDOHVRQWKHVDPH8,E\VLPSO\
FKDQJLQJWKHORFDOHGHQLWLRQDQGUXQQLQJWKHFRUUHFWPRGXOH
Advantages

ok

 ,WVXSSRUWVWHVWLQJPXOWLSOHORFDOHV
 $OOGHVFULSWLRQVDUHVWRUHGZLWKLQWKHOLEUDU\

Bo

 ,WLVREMHFWEDVHG
'LVDGYDQWDJHV

 7KHHQJLQHHUPXVWEHIDPLOLDUZLWK22WHFKQLTXHVWRXWLOL]HLWZHOO
 %HFDXVH WKLV WHFKQLTXH DOVR XVHV GHOLPLWHUV DV WKH QXPEHU RI ORFDOHV LQFUHDVH
PDLQWHQDQFHFDQEHFRPHFXPEHUVRPHLQFDVHVZKHUHORFDOHVWULQJVDUHYHU\ORQJ

Using a Class-based Centralized Delimited


Collection
7KLV DSSURDFK WDNHV LWV LQVSLUDWLRQ IURP WKH SUHYLRXV WHFKQLTXH ZKHUH HDFK  IXQFWLRQDO

http://KnowledgeInbox.com/store/

217

473'HVFULSWLYH3URJUDPPLQJ8QSOXJJHG

http://KnowledgeInbox.com/store/

FODVVRU3DJH2EMHFW 0DLQ3DJH/RJLQDQG/RJRXWHWF FRQWDLQVWKHLUUHVSHFWLYHORFDOL]HG


GHQLWLRQV7KHDERYHDSSURDFKFDQEHPRGLHGWRXWLOL]HDVLQJOHREMHFWFRQWDLQLQJDOO
ORFDOL]HGGHQLWLRQV
8VLQJWKLVPHWKRGFRQGHQVHVRXUIXQFWLRQDOFODVVHV 0DLQ3DJH&ODVVDQG/RJLQ3DJH&ODVV 
E\WDNLQJRXWDOOWKHORFDOHGHQLWLRQVDVVKRZQKHUH
Class MainPageClass
'Scripting.Dictionary built from LocalizedRepository

Private Content

ev
i

ew

Public Sub Action()



With Browser("name:=" & Content("title")) 'OR style
.Link("innertext:=" & Content("about-us")).Highlight 'DP style
End With
End Sub

ok

Pr

'builds the Dictionary from LocalizedRepository



If Not TypeName(Content) = "Dictionary" Then
Set Content = LocalizedRepository.MainPage()
End If
End Sub

Bo

Private Sub Class_Terminate()


Set Content = Nothing
End Sub
End Class

Dim MainPage
Set MainPage = New MainPageClass
Class LoginPageClass
'Scripting.Dictionary built from LocalizedRepository

Private Content

218

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

11

Pr

ev
i

ew

,>FA?P&@AJPE?=PEKJQOEJC5-=PD

ok

&JPNK@Q?PEKJ

Bo

With QTP 11, HP launched several new web testing capabilities to provide engineers
ZLWK JUHDWHU H[LELOLW\ ZKHQ WHVWLQJ :HE DSSOLFDWLRQV 2QH RI WKH LPSRUWDQW DGGLWLRQV
ZDV;3DWKIRU2EMHFW,GHQWLFDWLRQDTXHU\ODQJXDJHIRUVHOHFWLQJQRGHVIURPDQ;0/
GRFXPHQW 473 DXWRPDWLFDOO\ JHQHUDWHV DQG DVVLJQV D ;3DWK ZKLOH UHFRUGLQJ REMHFWV
RQ:HE DSSOLFDWLRQV +RZHYHU WKLV ;3DWK LV XVHG LQ WKH EDFNJURXQG DV D SHUIRUPDQFH
HQKDQFHPHQWGXULQJWHVWH[HFXWLRQ
,I473LGHQWLHVWKHZURQJREMHFWXVLQJWKHJHQHUDWHG;3DWKWKHQLWIDOOVEDFNWRXVXDO
GHVFULSWLRQSURSHUWLHV7RIRUFH;3DWKEDVHGLGHQWLFDWLRQIRUDQREMHFWZHQHHGWRDGG
;3DWK DV RQH RI WKH GHVFULSWLRQ SURSHUWLHV LQ WKH 25 7R EH DEOH WR XVH ;3DWK EDVHG
LGHQWLFDWLRQKDYLQJDVRXQGXQGHUVWDQGLQJRI;3DWKLVKLJKO\UHFRPPHQGHG

http://KnowledgeInbox.com/store/

223

2EMHFW,GHQWLFDWLRQXVLQJ;3DWK
http://KnowledgeInbox.com/store/

<td>
<span>Row1 span1</span><br/>
<span id="selectednode">Row1 span2 <!-- target -->
<p>TEST</p>
<p>REST</p>
</span>

ancestor-or-self
XPath selector: //SPAN[@id='selectednode']/ancestor-or-self::*

ok

Pr

ev
i

ew

<html>
<body>
<div id="forsomereason">
<span>This is before table</span><br/>
</div>
<table border="1">
<tr>
<td>
<span>Row1 span1</span><br/>
<span id="selectednode">Row1 span2 <!-- target -->
<p>TEST</p>
<p>REST</p>
</span><br/>

Bo

child

XPath selector: //SPAN[@id='selectednode']/child::*


<span id="selectednode">Row1 span2 <!-- target -->
<p>TEST</p>
<p>REST</p>
</span>

descendant
XPath selector: //SPAN[@id='selectednode']/descendant::*
<span id="selectednode">Row1 span2 <!-- target -->
<p>TEST</p>

http://KnowledgeInbox.com/store/

243

http://KnowledgeInbox.com/store/

12

ok

Pr

ev
i

ew

,>FA?P&@AJPE?=PEKJQOEJC 00

Bo

$V ZH VDZ LQ WKH ;3DWK FKDSWHU 2EMHFW ,GHQWLFDWLRQ FDQ EH PDGH YHU\ H[LEOH HYHQ
RIIHULQJWKHDELOLW\WRXWLOL]HWKHXQLTXHHOHPHQWVWRLGHQWLI\WKHQRQXQLTXHRQHV-XVWOLNH
ZLWK;3DWKZHZLOOXVH&666HOHFWRUVWRLGHQWLI\REMHFWVE\GLUHFWO\ORFDWLQJWKHWDUJHW
QRGHDQGDOVRE\XVLQJDQHLJKERULQJQRGHDVDQDQFKRU
7KLVLVJRLQJWREHDIDPLOLDUWRSLFIRUDZHEGHYHORSHURUDQ\RQHZKRKDVH[SHULHQFHVW\OLQJ
ZHESDJHV$&666HOHFWRULVXVHGWRVW\OHDQHOHPHQWE\SRLQWLQJWRLWVWDJLQFRQMXQFWLRQ
ZLWKDQ\DWWULEXWHVDVVRFLDWHGZLWKWKDWWDJ7KHV\QWD[RIXVLQJD&666HOHFWRULQ473LV
VLPLODUWRXVLQJDQ\RWKHUSURSHUW\YDOXHSDLULQWKH2EMHFW,GHQWLFDWLRQVHSDUDWHGE\WKH
:=GHOLPLWHU
7KHIROORZLQJFRGHVWDWHPHQWVKRZV&66VHOHFWRUXVDJHIRUD:HE%XWWRQZLWKWKH+70/
7$*HTXDOV,1387DQG&/$66HTXDOVEWQ7DUJHW
Browser("CSS Chapter").WebButton("css:=input.btnTarget").Click

http://KnowledgeInbox.com/store/

253

http://KnowledgeInbox.com/store/

13

ok

Pr

ev
i

ew

ObjectRepositoryUtil

Bo

QTP provides an Object Repository Automation API called ObjectRepositoryUtil. This


API provides a set of functions that can be used to read and/or write contents to a Shared
Object Repository (SOR). It can be used to update an external Object Repository except the
one already loaded in the memory.
There is a common misconception that this API can be used to add objects dynamically to
their script. This understanding is incorrect. It is possible, however, to create an OR using
the API and load it in the script using the RepositoriesCollection utility object.
%HIRUH SURFHHGLQJ IXUWKHU LW ZRXOG EH EHQHFLDO WR OLVW DOO WKH PHWKRGV VXSSRUWHG E\
ObjectRepositoryUtil. These are listed in the following table:

http://KnowledgeInbox.com/store/

265

http://KnowledgeInbox.com/store/

14

ok

Pr

ev
i

ew

Working with QTP XML OR

Bo

6KDUHG2EMHFW5HSRVLWRULHV 625V FDQEHH[SRUWHGWR;0/OHVEXWFDQQRWEHGLUHFWO\


ORDGHGLQD473VFULSWXVLQJWKH;0/IRUPDW+RZHYHUZHFDQORDGDQ625LQWKH765
OHIRUPDWDVZHVDZHDUOLHULQWKH&KDSWHU2EMHFW5HSRVLWRU\
+HUHZHZLOOH[SORUHKRZWRXVHWKHVHH[SRUWHG;0/VDQGJHWFRPSOHWHREMHFWGHVFULSWLRQV
IURPWKH;0/&RQVLGHUWKHIROORZLQJ2EMHFW5HSRVLWRU\LQ473

http://KnowledgeInbox.com/store/

271

http://KnowledgeInbox.com/store/

15

ok

Pr

ev
i

ew

Testing Web Services

Bo

Introduction

As web services become key areas of enterprise applications, the focus on testing them has
become increasingly important. A web service is used to provide a response to a clients
request. The request and response are sent and received respectively using the Simple
Object Access Protocol (SOAP). To test a web service, an automation engineer must carry
out the following steps:
1. 'HQHWKHSDUDPHWHUVWRVXSSO\WRWKHZHEVHUYLFH
2. 6HQGWKHUHTXHVWZLWKWKHGHQHGLQSXWSDUDPHWHUV
3. Parse response to verify expected versus actual values.
The process of sending a request and receiving a response is shown below:

http://KnowledgeInbox.com/store/

287

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

Celsius (C) for the unit (string).

Figure 15.2 Sample Temperature Web Service

Bo

ok

The snapshot below is the output from invoking the WebMethod:

Figure 15.3 Sample WebMethod Input and Output

292

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

16

Pr

ev
i

ew

Coding Scripts in .NET

Bo

ok

There are times when advanced users want the ability to code QTP scripts in a different
scripting language than VBScript. A few such instances include the need for better
exception handling (using Try-Catch-Finally), designing forms for user interaction,
Object-Oriented features, need for Optional Parameters and better support for Win32 APIs
(VBScript's support through the Extern object is very limited) etc. It is not possible to use
any language except VBScript inside QTP, yet it is still possible to create a COM-based
bridge for languages that support COM. We will be demonstrating such a bridge in this
chapter built in C# and Visual Basic using .NET Framework 4.0. Before we see how the
bridge is created, there are few concepts that we need to understand.

QTP's Communication with an Out-of-Process


COM Object
Consider the following code:

http://KnowledgeInbox.com/store/

323

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

Set oXlApp = CreateObject("Excel.Application")


oXLApp.Visible = True
Set oXLBook = oXLApp.WorkBooks.Open("C:\Test.xls")
Set oXLSheet = oXLBook.WorkSheets(1)
oXLSheet.Cells(1,1) = "Anshoo"
oXLSheet.Cells(2,2) = "Tarun"

Bo

ok

Pr

ev
i

ew

In this code an oXLSheet.Cells object is used to pass a value to an Excel Worksheet. Even
though Excel runs as a separate process in the system, we can still pass values to it. This
is called out-process communication. It works through use of a proxy object in the caller
SURFHVVZKLFKURXWHVWKHFDOOXVLQJ5HPRWH3URFHGXUH&DOO 53& DVVKRZQLQWKHJXUH
below:

Figure 16.1 Out-Process Communication

324

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

ok

Pr

ev
i

Web Extensibility

ew

17

Bo

Introduction

The Web Extensibility Add-in coupled with the Extensibility Accelerator for HP Functional
Testing provides a platform that enables Automation Engineers to extend support for
custom web controls and toolkits.
A compelling case to opt for Extensibility is in a situation where some web controls which
are not supported out-of-the-box are recognized as generic WebElements; these generic
objects may implement the behavior of a TextBox, Link, Button or List etc. Since the Web
$GGLQ GRHV QRW UHFRJQL]H WKHLU VSHFLF EHKDYLRU 473 PDSV WKHP WR WKH :HE(OHPHQW
class. Every such generic object thus ends up supporting the functions/methods/events of
the WebElement class.
This is where the web add-in Extensibility plays an important role because a control can

http://KnowledgeInbox.com/store/

339

http://KnowledgeInbox.com/store/

18

ok

Pr

ev
i

ew

Creating Reserved Objects

Bo

Introduction

A reserved object allows you to add a specialized keyword to QuickTest which unlike custom
classes provides you with IntelliSense. For example, the Environment object is a reserved
object with the ProgId of Mercury.MicEnvironment. Similarly, a Description object
(Description.Create) is another reserved object with ProgId of Mercury.DescObjCreator.
Just like with these reserved objects, it is also possible to create custom reserved objects.
At runtime, QuickTest creates a single instance of the reserved object as required by the
test code. Unlike instances of other objects, such as references to custom classes or classic
COM objects (Scripting.Dictionary or FileSystemObject objects created explicitly during
Test-run, for example), a reserved object is created on demand when referenced during
7HVWUXQ8VDJHDQGFUHDWLRQRI5HVHUYHG2EMHFWVZDVUVWVKRZQLQWKHGRFXPHQWDWLRQ
made available with QTP Plus (QTP 8.2).

http://KnowledgeInbox.com/store/

393

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

Appendix A - Approaches for Issue


Resolution

Bo

ok

Problem 1 Application crashes when launched


with QTP already open
Some applications have problems with QTPs ActiveX add-in. In such cases the application
FUDVKHVZKHQ473LVRSHQEXWZRUNVQHZKHQ473LVFORVHG:HFDQXQORDGWKH$FWLYH;
DGGLQLILWLVQRWUHTXLUHGZKLFKXVXDOO\[HVWKHSUREOHP,IWKH$FWLYH;DGGLQQHHGVWR
EHORDGHGWKHUHDUHDIHZSRVVLEOH5HJLVWU\[HVWKDWZHFDQWU\
1. If IE crashes with a Non-Silverlight application
2SHQUHJHGLWH[H%URZVHWREHORZPHQWLRQHGNH\
HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest
Professional\MicTest\ActiveX Add-in

&UHDWHDQHZYDOXHZLWKWKHQDPH8VH%%+RRNDQGVHWWKHYDOXHDV

http://KnowledgeInbox.com/store/

401

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

Appendix B - Performance Benchmarks

ok

Introduction

Bo

You have decided what test cases need to be automated. You have selected the right
automated tool for your environment. You have even created automated tests that are
robust and tend to be resistant to changes in the UI. However, how do your tests perform?
Are there unnecessary Wait statements in your code? Are you using techniques that place
more than the required stress on the Automation tool?
8QWLOQRZZHKDYHGHVFULEHGLQGHSWKKRZWRZRUNZLWK2EMHFW,GHQWLFDWLRQLQGLIIHUHQW
scenarios and with different technologies. In this section, we will describe which techniques
result in code that performs faster. Please note that we are not comparing the advantages
and disadvantage of one approach over another. Each approach detailed up until now has
its own pros and cons. This chapter merely compares the performance difference between
WHFKQLTXHVZHURXWLQHO\XVHLQ2EMHFW,GHQWLFDWLRQ
To run our tests and compare difference between different techniques, we are going to use

http://KnowledgeInbox.com/store/

413

http://KnowledgeInbox.com/store/

C
2

ok

Pr

ev
i

ew

Appendix C - XPath vs CSS

XPath vs. CSS: A Comparison

Bo

This table summarizes both XPath and CSS Selectors. Both Selectors have been discussed
in detail in Chapters 11 and 12. This appendix compares both side-by-side.
Select By
Element
ID
Class
Attribute

XPath

CSS

//p

//span[@id='user']

span#user

//span[@class='user']

span.user

//span[@name='user']

span[name='user']

http://KnowledgeInbox.com/store/

423

http://KnowledgeInbox.com/store/

D
2

Pr

ev
i

ew

Appendix D - Nesting of
RegisterUserFunc Methods

ok

We have already seen how RegisterUserFunc works in QTP. Now lets see what happens
when RegisterUserFunc is used in a nested fashion. Consider the following code:

Bo

'User default timeout method


Private DEFAULT_TIMEOUT
DEFAULT_TIMEOUT = 10
'The new exist method
Function NewExist(ByVal Obj, ByVal timeout)
If timeout = -1 Then timeout = DEFAULT_TIMEOUT
If Obj.Exist(timeout) Then
Print("Object does exist")
NewExist = True
Else
Print("Object doesn't exist")
Reporter.ReportEvent micFail, "New Exist", "The object doesn't exist"
NewExist = False
End If

http://KnowledgeInbox.com/store/

427

http://KnowledgeInbox.com/store/

Eval and Execute

Pr

ev
i

ew

Appendix E - Eval and Execute

Bo

ok

The Eval function and Execute statement provide the ability to evaluate and execute
dynamic code at runtime. Evals purpose is to evaluate a string and return the evaluation
result. Execute simply interprets a string expression and executes it. An example of Eval
and Execute is shown below:
Execute "Dim x, y : x = 2 : y = 4"
MsgBox Eval("x = y")

NOTE: Unlike the Execute statement, Eval is a function


and it can return a value.

As stated earlier, Eval returns the result of the string evaluation whereas Execute will

http://KnowledgeInbox.com/store/

433

http://KnowledgeInbox.com/store/

ok

Pr

ev
i

ew

Appendix F - Cross-Browser Tests

Bo

DOM Differences between Browsers


DOM methods used in Firefox are case-sensitive as opposed to IE and Chrome, which are
case-insensitive.
When using DOM to access HTML nodes, give consideration to the methods case. For
example, in Firefox getElementsByTagName will work but getelementsbytagname will
fail. With IE, case is not an issue so either will work. Consider the statement below:
MsgBox Browser("Google").Page("Google").Object.
getelementsbytagname("input").length

If you run the above statement in Firefox, QTP will complain:

http://KnowledgeInbox.com/store/

437

Index

http://KnowledgeInbox.com/store/

Index
Symbols
_JAVA_OPTIONS ....................................................................................................................................... 8

A
Adding objects to SOR.............................................................................................................................. 20

ew

BDB file ....................................................................................................................................................... 16


Browser Identification Issues ................................................................................................................... 77
Brower Identification using a Unique OpenURL Property.............................................................. 78
Browser Identification using OpenTitle .............................................................................................. 78

ev
i

Bo

ok

Pr

Checking Appearance using Style Sheets ............................................................................................. 147


Checking Object Visibility .................................................................................................................. 147
ChildItem.................................................................................................................................................. 172
ChildItemCount ...................................................................................................................................... 172
ChildObjects ............................................................................................................................................ 123
ChildObjects return 0 objects when searching WebElement using just HTML Tag .................. 131
Detecting if an object has been derived using ChildObbjects ....................................................... 132
Enumerating ChildObjects ................................................................................................................... 64
Limitations of ChildObjects in QTP 10 or lower ............................................................................ 130
Performing an Action on Multiple Objects ........................................................................................ 88
Using Init or RefreshObject on Derived Objects............................................................................. 129
Coding Scripts in .NET .......................................................................................................................... 323
Converting a DOM object to a QTP Test Object ................................................................................ 144
Converting an OR-based script to a DP-based script ........................................................................... 69
CSS Selectors
Implementing CSS Selectors in QTP ................................................................................................ 260
Testing CSS Selectors with FirePath .................................................................................................. 258
Custom CheckPoints................................................................................................................................. 66

D
Descriptive Programming ........................................................................................................................ 55

http://KnowledgeInbox.com/store/

445

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

Pr

ev
i

ew

Common Mistakes................................................................................................................................. 79
Enumerating ChildObjects ................................................................................................................... 64
Implicit and Explicit Properties ........................................................................................................... 58
Keyword-based Descriptive Programming Object Repository ....................................................... 93
Converting QTP SOR to Keyword-based DP OR......................................................................... 107
Enhancing the Keyword-based Object Repository......................................................................... 99
Enumeration of Child Objects......................................................................................................... 104
Instantiating a Test Object ................................................................................................................. 96
Storing the Object Repository ........................................................................................................... 98
Test Object Aliases ............................................................................................................................ 103
Using a Hybrid OR (DP plus a Regular OR) ................................................................................. 106
Object Casting ........................................................................................................................................ 88
Object Spy ............................................................................................................................................... 56
Test Object Override ............................................................................................................................. 86
The micclass Identifier .......................................................................................................................... 63
Using a VBScript DP Object Repository ............................................................................................ 72
Using Description Objects .................................................................................................................... 60
Using Description Strings ..................................................................................................................... 63
Using Descriptive Programming in Scripts........................................................................................ 91
When to use Descriptive Programming ............................................................................................. 59

Bo

ok

Eval Function ........................................................................................................................................... 433


Execute Statement ................................................................................................................................... 433
Extensibility Accelerator......................................................................................................................... 349
Extern ........................................................................................................................................................ 411

GetDOMObjectByPath........................................................................................................................... 151
getElementById ....................................................................................................................................... 138
getElementsByName ........................................................................................................................137,153
GetRowWithCellText .............................................................................................................................. 171

H
HTML DOM ............................................................................................................................................ 133
Binding to an Element using HTML DOM ..................................................................................... 142
Checking Appearance using Style Sheets ......................................................................................... 147
Converting a DOM object to a QTP Test Object ............................................................................ 144

446

http://KnowledgeInbox.com/store/

Index

http://KnowledgeInbox.com/store/

ew

Selecting a Radio Button by Text ....................................................................................................... 150


Traversing HTML tree nodes ............................................................................................................. 145
When Not to Use HTML DOM ......................................................................................................... 136
When to Use HTML DOM ................................................................................................................ 134
HTML DOM Objects ............................................................................................................................. 136
Checkbox .............................................................................................................................................. 140
Combo Box or List box ....................................................................................................................... 140
HTML Element Object ....................................................................................................................... 137
HTML Elements Collection ............................................................................................................... 137
HTML Node ......................................................................................................................................... 136
HTML Table ......................................................................................................................................... 141
Link and Button (Click) ...................................................................................................................... 138
Radio Group ......................................................................................................................................... 141
Textbox .................................................................................................................................................. 139
The Document Object ......................................................................................................................... 136

ev
i

ok

Pr

IBM_JAVA_OPTIONS ............................................................................................................................... 8
Identification Properties
Assistive Properties................................................................................................................................ 12
Mandatory Properties ........................................................................................................................... 12
Ordinal Identifiers ................................................................................................................................. 12
Installing the Web Extensibility Add-in ............................................................................................... 344

Bo

JAVA_TOOLS_OPTIONS.......................................................................................................................... 8

Local Object Repository (LOR) ............................................................................................................... 16


Local OR vs Shared OR ............................................................................................................................ 41

O
Object Identification Algorithm .............................................................................................................. 13
Object Identification Settings .................................................................................................................. 15
Object References Unusable after Navigation ....................................................................................... 86
Object Repository Parameters (ORP)..................................................................................................... 28
ObjectRepositoryUtil
Converting between TSR file and XML Files ................................................................................... 266

http://KnowledgeInbox.com/store/

447

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

Printing Names of all the WebTable in an OR ................................................................................. 268


Retrieving an Object Directly and Modifying its Properties ......................................................... 269
Ordinal Identifiers
CreationTime .......................................................................................................................................... 12
Index ........................................................................................................................................................ 12
Location .................................................................................................................................................. 12
Problems with Ordinal Identifiers ....................................................................................................... 73

P
Performance Benchmarks ...................................................................................................................... 413
Results ................................................................................................................................................... 420

ew

Q
QTP .NET COM Bridge ......................................................................................................................... 325

ev
i

Pr

RepositoriesCollection.............................................................................................................................. 52
Reserved Objects ..................................................................................................................................... 393
Creating an Icon ................................................................................................................................... 397
How to Create....................................................................................................................................... 394

Bo

ok

Selecting a Radio Button by Text........................................................................................................... 150


selectNodes............................................................................................................................................... 278
Shared Object Repositories (SOR)
Working with QTP XML OR ............................................................................................................. 271
Shared Object Repository (SOR)............................................................................................................. 18
Adding Object through Object Spy ..................................................................................................... 22
Define Object Filter ............................................................................................................................... 23
Defining the Object Manually .............................................................................................................. 20
Importing and Exporting OR from XML ........................................................................................... 32
Loading SOR at Design-time ............................................................................................................... 53
Loading SOR at Run-time .................................................................................................................... 52
Locating the Object in OR .................................................................................................................... 27
Navigate and Learn ................................................................................................................................ 23
Object Repository Comparison Tool .................................................................................................. 40
Object Repository Merge Tool ............................................................................................................. 39
Object Repository Parameters (ORP) ................................................................................................. 28

448

http://KnowledgeInbox.com/store/

Index

http://KnowledgeInbox.com/store/

Update from Local Object Repository ................................................................................................ 33


SMART Identification ............................................................................................................................... 42
Disabling SMART Identification using Code .................................................................................... 49
sourceIndex .............................................................................................................................................. 144

Pr

ev
i

ew

Testing Web Services


Testing SOAP Request and Response................................................................................................ 320
Testing Web Services Programmatically........................................................................................... 311
XMLDOM .......................................................................................................................................... 316
XMLHTTPRequest ........................................................................................................................... 312
XMLUtil .............................................................................................................................................. 315
Testing Web Services using the Web Service Add-in ...................................................................... 293
Auto-Generated Code....................................................................................................................... 302
Verifying XML Response Values ..................................................................................................... 308
Manually adding the nodes............................................................................................................. 308
Manually supplying XML ............................................................................................................... 309
Web Services Testing Wizard ........................................................................................................... 297
XML Checkpoint Properties ............................................................................................................ 306
WebService Object Methods .............................................................................................................. 309
Test Object Configuration File .............................................................................................................. 380

ok

Bo

Utility Objects
Extern .................................................................................................................................................... 411
RepositoriesCollection .......................................................................................................................... 52
Repository ............................................................................................................................................... 30

VB.NET COM Bridge ............................................................................................................................. 329


Visual Relation Identifiers (VRI) ........................................................................................................... 113
Creating Visual Relation Identifiers using Code ............................................................................. 121
Visual Relational Identifiers using HTML DOM ............................................................................ 157

W
Web Extensibility
Cases to opt for..................................................................................................................................... 339
Developing Toolkit Support Set with Extensibility Accelerator .................................................... 349

http://KnowledgeInbox.com/store/

449

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

Bo

ok

Pr

ev
i

ew

Extensibility Accelerator
Adding new Custom Control .......................................................................................................... 352
Creating a New Project ..................................................................................................................... 349
Defining operations .......................................................................................................................... 359
Defining Properties ........................................................................................................................... 364
Deploying the Solution ..................................................................................................................... 368
Deploying Toolkit Support Set on Other Machines ..................................................................... 376
_elem ................................................................................................................................................... 361
General test object settings .............................................................................................................. 350
logical_name property ...................................................................................................................... 367
Mapping the Control ........................................................................................................................ 354
Using the Custom Test Object Class with QTP ............................................................................. 369
_util ..................................................................................................................................................... 364
Installing the Web Extensibility Add-in ........................................................................................... 344
Limitations and Issues ......................................................................................................................... 390
Recording Generic Controls without Extensibility ......................................................................... 347
Test Object Configuration File
ClassInfo element .............................................................................................................................. 383
Description element .......................................................................................................................... 384
IconInfo element ............................................................................................................................... 385
IdentificationProperty element........................................................................................................ 384
Load element...................................................................................................................................... 385
ReturnValueType element ................................................................................................................ 385
TypeInformation element................................................................................................................. 382
The Toolkit Configuration file............................................................................................................ 386
Conditions element ........................................................................................................................... 387
Control element ................................................................................................................................. 387
Filter element ..................................................................................................................................... 388
Identification element ....................................................................................................................... 387
Settings element ................................................................................................................................. 388
Using Functions to Define Filters ...................................................................................................... 389
Using Functions to Get Property Values .......................................................................................... 390
WebTable
Asynchronous Table Loading ............................................................................................................. 177
Clicking inside a WebTable ................................................................................................................ 176
Finding a Row containing Specific Text............................................................................................ 173
Performing Operations on Objects Inside the Table....................................................................... 172
Retrieving the Parent WebTable from an Element .......................................................................... 178
WebTable Identification in QTP ............................................................................................................ 167

450

http://KnowledgeInbox.com/store/

Index

http://KnowledgeInbox.com/store/

Working with Multiple Browsers ............................................................................................................ 75


Working with QTP XML OR ................................................................................................................. 271
Finding Object Nodes using Names.................................................................................................. 278
Finding Root Object Names ............................................................................................................... 277
Finding String Descriptions for Child Objects ................................................................................ 282
Getting Object Descriptions from Names ........................................................................................ 278
Getting Object Description using Path ............................................................................................. 281
Getting the Object from the Description ......................................................................................... 283
Using ORPath to Shorten Code ......................................................................................................... 283
Writing scripts in .NET .......................................................................................................................... 323

Bo

ok

Pr

ev
i

ew

XMLDOM ................................................................................................................................................ 316


XMLHTTPRequest ................................................................................................................................. 312
XMLUtil .................................................................................................................................................... 315
XPath and CSS Comparison .................................................................................................................. 423
XPath Axes
ancestor ................................................................................................................................................. 242
ancestor-or-self..................................................................................................................................... 243
child ....................................................................................................................................................... 243
descendant ............................................................................................................................................ 243
descendant-or-self ............................................................................................................................... 244
following ............................................................................................................................................... 244
following-sibling .................................................................................................................................. 245
parent..................................................................................................................................................... 245
preceding............................................................................................................................................... 245
preceding-sibling ................................................................................................................................. 246
XPATH Identification
Automatic XPath .................................................................................................................................. 226
contains ................................................................................................................................................. 231
ends-with .............................................................................................................................................. 231
Implementing XPath in QTP ............................................................................................................. 232
Learning XPath on Firefox ................................................................................................................. 227
Operators .............................................................................................................................................. 230
Selecting Parent Nodes using Children ............................................................................................ 237
starts-with ............................................................................................................................................. 231
Using Manual XPath with Object Repository .................................................................................. 238
XPath Axes.....................................................................................................................................240,241
XPath Expressions, Wildcards, Operators and Functions.............................................................. 229

http://KnowledgeInbox.com/store/

451

QTP Descriptive Programming Unplugged

http://KnowledgeInbox.com/store/

Bo

ok

Pr

ev
i

ew

XPath Functions................................................................................................................................... 231

452

http://KnowledgeInbox.com/store/

http://KnowledgeInbox.com/store/

And I thought I knew QTP!


How many times have you wished that there
was somebody who could clear some niggling
doubts about a particular aspect of QTP? Or
H[SODLQ VRPH GLIFXOWWRJUDVS FRQFHSWV DQG
smart workarounds? Or maybe show you some
RI473VOHVVHUNQRZQIHDWXUHV"

ev
i

ew

:ULWWHQ E\ WKH DXWKRU RI WKH EHVWVHOOLQJ


QuickTest Professional Unplugged, this book
does just that in the form of a gripping story
which will keep you turning every page in
anticipation. And I Thought I Knew QTP!
QTP Concepts Unplugged is unique in the way
it seeks to explain the various concepts through
LWVLQWHUHVWLQJHDV\WRIROORZDQGLQQRYDWLYHVWRU\WHOOLQJVW\OH UDUHO\XVHGIRUWHFKQLFDO
books). Instead of following a textbook format, this book is more like a technical novel.

ok

Pr

The story follows the journey of Nurat, who encounters a series of challenging interviews
LQ D VHDUFK IRU KLV GUHDP MRE 7KH TXHVWLRQDQGDQVZHU VW\OH RI WKH ERRN DGGUHVVHV
many of the questions frequently asked by QuickTest practitioners and aims to correct
common mistakes and misunderstandings surrounding QTP by providing clear and concise
explanation of the topics at hand.

Bo

Whether it is to brush up your QTP knowledge and skills or simply to satiate your curiosity
DERXWKRZDVHDVRQHG,7YHWHUDQIDUHGLQDQRKROGVEDUUHGLQWHOOHFWXDOGXHORQ473WKLV
book is sure to leave you astonished with its pace of narration, expertise, and sheer breadth
of topics covered.
,6%1
For more details, please visit www.KnowledgeInbox.com/books/

http://KnowledgeInbox.com/store/

453

http://KnowledgeInbox.com/store/

QuickTest Professional Unplugged


4XLFN7HVW 3URIHVVLRQDO 8QSOXJJHG WKH UVW ERRN
released by Tarun Lalwani, has received much
recognition for being the most detailed and creative
book on QTP. It was awarded the Best Automation
Book in the 2nd ATI Automation Honors.

Pr

ev
i

ew

Even though this book contains a plethora of


information to help QTP starters come up to speed,
WKHUH DUH DOVR PDQ\ QHYHUVHHQEHIRUH WRSLFV DQG
techniques that will give advanced users an edge.
This mix makes it the recommended option for those
aspiring to be not only advanced users, but experts.
Containing previously untouched and undocumented
features which are not offered in standard QuickTest
documentation, QuickTest Professional Unplugged
has served as the key desktop reference for QuickTest issues for over three years and
continues to set an unrivaled example.

Bo

ok

QuickTest Professional 2nd Edition includes all features of QTP 11 as well as additional
XSGDWHVWKDWKDYHEHHQLQWURGXFHGRYHUWKH\HDUV:LWKDEUDQGQHZLQGHSWKFKDSWHURQ
Object Repository, this book delivers a clear message: QuickTest is an immensely powerful
automated testing tool. QuickTest Professional 2nd Edition brings to light a plethora
RIKLGGHQDQGKLJKO\LQQRYDWLYHIHDWXUHVDQGLVDPXVWKDYHYROXPHIRUDQ\473XVHUV
bookshelf.

,6%1

For more details, please visit www.KnowledgeInbox.com/books/

454

http://KnowledgeInbox.com/store/

Bo
ok
ie
w

ev

Pr

You might also like