© 2015 Incessant Technologies Incessant Technologies A Value Adding Relationship
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 1/40
© 2015 Incessant Technologies
Incessant TechnologiesA Value Adding Relationship
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 2/40
© 2015 Incessant Technologies
UFT 12.5 G.V.Sesha kumari
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 3/40
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 4/40
© 2015 Incessant Technologies
STRU0TURE
1.'E0T RE#'S-T'R-ES
2.E3TERNA4 ATASEETS
%.ENV-R'N6ENT VAR-A4ES
*.RE0'VER7 S0ENAR-' 6ANAGER
5.-NTEGRAT-'N 'F /T# AN /0
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 5/40
© 2015 Incessant Technologies
ES0R-#T-VE #R'GRA66-NG
Descriptive programming is used to s!ript (ased onordinal identi9ers ,hi!h ,ill ena(le /T# to a!t on those
o()e!ts ,hen t,o or more o()e!ts ha"e same properties.
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 6/40
© 2015 Incessant Technologies
ES0R-#T-'N 'E0T
A es!ription '()e!t in /T# is a !olle!tion o test o()e!tpropert& and "alue pairs. Ea!h o()e!t in the app!lassi9es to (e part o a !olle!tion.
Set oes! : es!ription.0reate
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 7/40© 2015 Incessant Technologies
0-4 'E0T 6ET'
0hild'()e!ts 6ethod
The 0hild'()e!ts method is used to !reate o()e!t
!olle!tions using a parent o()e!t.
Set !ol'()e!t : #arent'()e!t.0hild'()e!ts;oes!<
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 8/40© 2015 Incessant Technologies
0-4 'E0TS
-n S!ripting ,e !ome a!ross s!enarios ,here ,e needto !ount the o()e!ts in the appli!ation or e"en highlighta !hild o()e!t like highlighting a te$t (o$ or !he!k andun!he!k !he!k (o$es using s!ripting in /T#.
E3=S!ript to !ount the num(er o !hild o()e!ts o >ightreser"ation appli!ationSet !hd?o() : ialog;@te$t=:4ogin@<.0hild'()e!tsmsgbox !hd?o().!ount
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 9/40© 2015 Incessant Technologies
RUNT-6E 'E0TS
These are !aptured
No set ro propert&
1.GET R' #R'#ERT7
2.SET T' #R'#ERT7
%.GET T' #R'#ERT7
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 10/40© 2015 Incessant Technologies
GET T' #R'#ERT7
GetTOProperties=GetT'#roperties is used to enumerate all the properties oan o()e!t used or identi9!ation.E$ample=Set a(! : ro,ser;@Google@<.#age;@7ahoo 6ail= The
(est@<.Be(Edit;@login@<Set #rops : a(!.GetT'#roperties#rops0ount : #rops.0ountFor i : C To #rops0ount D 1#ropName : #rops;i<.Name (.Name = Returns the name of
property)#ropValue : #rops;i<.Value (.value = Returns the value of property)
6sgo$ #ropName @ : @ #ropValueNe$t
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 11/40© 2015 Incessant Technologies
GET R' #R'#ERT7
GetR'#ropert&=
GetR'#ropert& allo,s us to get the !urrent "alue o atest o()e!t propert&. This means that unlike theGetT'#ropert& and GetT'#roperties !ommands
GetR'#ropert& reuires the test o()e!tHs !orrespondingruntime o()e!t to e$ist.
asi!all& &ou ,ould use GetR'#ropert& to get the "alueo an o()e!t propert& during runtime su!h as the
!urrent listI!om(o item sele!tion or the te$t in aBe(Edit or the siJe o an o()e!t ;,idth height<.
#rint ro,ser;@3@<.#age;@7@<. Be(4ist;@J@<.GetR'#ropert&;@sele!ted item inde$@<
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 12/40© 2015 Incessant Technologies
SET R' #R'#ERT7
The SetTOProperty !hanges the "alue o a test o()e!t propert&. 0hangingthe propert& doesnKt aLe!t the 'R or A!ti"e S!reen (ut )ust the ,a& /T#identi9es the o()e!t during runtime. A!tuall& this !hanges the properties othe temporar& !op& o the o()e!t stored in RA6 (& /T#.An& !hanges &ou make using the SetTOProperty method appl& onl& duringthe !ourse o the run session and do not aLe!t the "alues stored in the test
o()e!t repositor&.
E$ample=Set o() : ro,ser;@name=:Sign in to 7ahoo@<.#age;@title=:Sign in to 7ahoo@<.Be(Edit;@html id=:username@<msg(o$ o().GetT'#ropert&;@html id@<
'Would retrieve the object html id from the test object description, whetherit's in the R or !" de#ned'Now we set the name property
o().SetT'#ropert& @name@ @loginJJJJJ@'$nd retrieve it msg(o$ o().GetT'#ropert&;@name@<
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 13/40© 2015 Incessant Technologies
E3A6#4E STE#S F'R ES0R-#T-VE #R'GRA66-NG
1.4aun!h ro,ser.2.0he!k ,hether the !orre!t (ro,ser opened.
%.Ensure the userName pass,ord edits and the SignD-n(utton e$ist.
*.Set the userName and pass,ord and 0li!k SignD-n.
6ake sure the (ro,ser na"igated to the !orre!t page.
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 14/40© 2015 Incessant Technologies
STE# 1
Step 1: Launch Broser
KBe ,ill use S&stemUtil.Run to laun!h our target (ro,ser
S&stemUtil.Run @ie$plore.e$e@@http=IIne,tours.demoaut.!omI@
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 15/40
© 2015 Incessant Technologies
STE# 2
Step !: "hec#ing i$ the correct broser opene%
The 2 ne, !on!epts in this step are=
&eporter Ob'ect= This o()e!t is used to send indi"idual reports to the testresults. -n other ,ords ,hen the test ends &ou !an see the reported e"entsin &our Test results.
(xitTest= A utilit& statement a"aila(le to /T# that ena(les it to !omplete e$ita Test. -n other ,ords ,hen this statement e$e!utes the test e$e!ution ends
- ro,ser; @title=:Bel!ome= 6er!ur& Tours@ <.E$ist; 15 < Then
Reporter.ReportE"ent mi!#ass @Step 1D 4aun!h@ @0orre!t (ro,ser ,aslaun!hed.@
Else Reporter.ReportE"ent mi!Fail @Step 1D 4aun!h@ @ro,ser ailed to laun!h.@
E$itTest
End -
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 16/40
© 2015 Incessant Technologies
STE# %
Step ): (nsure the user*ame+ passor% e%its an% the Sign,In button exist-
KNoti!e the use o the ,ild!ard !hara!ter (elo,
- ro,ser;@title=:Bel!ome=.M@<.#age;@title=:Bel!ome.M@<.Be(Edit;@name=:userName@<.E$ist;C< Then
Kset username
- ro,ser;@title=:Bel!ome=.M@<.#age;@title=:Bel!ome.M@<.Be(Edit;@name=:pass,ord@<.E$ist;C< Then
Kset pass,ord - ro,ser;@title=:Bel!ome=.M@<.#age;@title=:Bel!ome.M@<.-mage;@name=:login@ <.E$ist;C< Then
K!li!k (utton
Else
Kreport that SignD-n (utton ,as not ound
End -
Else Kreport that the pass,ord edit ,as not ound
End -
Else
Kreport that the userName edit ,as not ound
End -
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 17/40
© 2015 Incessant Technologies
STE# *
Step .: Set the user*ame an% passor% an% "lic# Sign,In-
KNoti!e the use o the ,ild!ard !hara!ter (elo,
Bith ro,ser;@title=:Bel!ome=.M@<.#age;@title=:Bel!ome.M@<
- Be(Edit;@name=:userName@<.E$ist;C< Then
Be(Edit;@name=:userName@<.Set @test@
- Be(Edit;@name=:pass,ord@<.E$ist;C< Then
Be(Edit;@name=:pass,ord@<.Set @test@ - -mage;@name=:login@ <.E$ist;C< Then
-mage;@name=:login@ <.0li!k
Else
Reporter.ReportE"ent mi!Fail @SignD-n utton Error@ @utton not ound.@
End -
Else
Reporter.ReportE"ent mi!Fail @#ass,ord Edit Error@ @Edito$ not ound.@ End -
Else
Reporter.ReportE"ent mi!Fail @UserName Edit Error@ @Edito$ not ound.@
End -
End Bith
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 18/40
© 2015 Incessant Technologies
STE# 5
Step /: 0a#e sure the broser navigate% to thecorrect page
KS&n!hroniJe ,ith a (ro,ser
ro,ser; @title=:.M@ <.S&n!
KBait 1 se!ond or (ro,ser ,ith @Find a Flight@ title toe$ist
- ro,ser; @title=:Find a Flight.M@ <.E$ist; 1 < Then
Reporter.ReportE"ent mi!#ass @4ogin@ @4ogin
su!!essul@Else
Reporter.ReportE"ent mi!Fail @4ogin@ @4ogin ailed@
End -
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 19/40
© 2015 Incessant Technologies
A44 STE#S T'GETER
KBe ,ill use S&stemUtil.Run to laun!h our target (ro,ser
S&stemUtil.Run @ie$plore.e$e@ @http=IIne,tours.demoaut.!omI@
- ro,ser; @title=:Bel!ome= 6er!ur& Tours@ <.E$ist; 15 < Then
Reporter.ReportE"ent mi!#ass @Step 1D 4aun!h@ @0orre!t (ro,ser ,as laun!hed.@
Else
Reporter.ReportE"ent mi!Fail @Step 1D 4aun!h@ @ro,ser ailed to laun!h.@
E$itTest
End -
KNoti!e the use o the ,ild!ard !hara!ter (elo,
Bith ro,ser;@title=:Bel!ome=.M@<.#age;@title=:Bel!ome.M@<
- .Be(Edit;@name=:userName@<.E$ist;C< Then
.Be(Edit;@name=:userName@<.Set @test@
- .Be(Edit;@name=:pass,ord@<.E$ist;C< Then
.Be(Edit;@name=:pass,ord@<.Set @test@
- .-mage;@name=:login@<.E$ist;C< Then
.-mage;@name=:login@<.0li!k
Else
Reporter.ReportE"ent mi!Fail @SignD-n utton Error@ @utton not ound.@
End -
Else
Reporter.ReportE"ent mi!Fail @#ass,ord Edit Error@ @Edito$ not ound.@
End -
Else
Reporter.ReportE"ent mi!Fail @UserName Edit Error@ @Edito$ not ound.@ End -
End Bith
ro,ser; @title=:.M6er!ur&.M@ <.S&n!
- ro,ser; @title=:Find a Flight.M@ <.E$ist; 1 < Then
Reporter.ReportE"ent mi!#ass @4ogin@ @4ogin su!!essul@
Else
Reporter.ReportE"ent mi!Fail @4ogin@ @4ogin ailed@
End -
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 20/40
© 2015 Incessant Technologies
E3A6#4E 'F GET 4-N+S
Simple steps to get num(er o links on a page are as(elo,..
1.First !reate the des!ription o()e!t.
2.Ne$t gi"e the propert& "alue used to identi& &ouro()e!t;-n our !ase its KlinkK<.
%.Ne$t ,rite the !ode or the page on ,hi!h &ou ,ant to9nd the num(er o links
*.Bith the help o the !hild o()e!ts propert& ,e !an get
the num(er o o()e!ts holding parti!ular des!ription
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 21/40
© 2015 Incessant Technologies
E3A6#4E GET 4-N+S
set linko()e!t:es!ription.0reate DD This line is used to!reate des!ription o()e!tlinko()e!t;@6i!!lass@<."alue:@link@ DD This line is usedto identi& the propert&.; -n our !ase its link<
seta:ro,ser;@Google@<.#age;@Google@<.0hild'()e!ts;linko()e!t< DD This line is used to return the !hildo()e!tsha"ing K4inko()e!tK des!ription.link!ount: a.0ount DDD This line is used get num(er o
links on a ,e(page6sgo$ link!ount
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 22/40
© 2015 Incessant Technologies
0'E T' GET 4-N+S
set a: des!ription.!reate
a;@mi!!lass@<."alue:@links@
set (:(ro,ser;<.page;<.!hildo()e!ts;a<
!:(.!ount
msg(o$ !or i: C to !D1
d:(.getropropert&;@name@<
msg(o$ d
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 23/40
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 24/40
© 2015 Incessant Technologies
-0T-'NAR7 'E0TS
0etho%s o$ Dictionary Ob'ect
Add DDDDDDD Adds ne, ke&Ditem pair in the di!tionar& o()e!tE$ists DDDD returns true i the gi"en ke& e$ists in the di!tionar& o()e!t-tems DDDDD returns the arra& !ontaining all items in the di!tionar& o()e!t+e&s DDDDDD returns the arra& !ontaining all ke&s in the di!tionar& o()e!tRemo"e DDDD remo"es the ke&Ditem pair ,ith gi"en ke& rom the
di!tionar& o()e!tRemo"eAll D remo"es all ke&Ditem pairs rom the di!tionar& o()e!t
Properties o$ Dictionary Ob'ect
0ountDDDDDDDD returns the total num(er o ke&s in the di!tionar& o()e!t
-temDDDDDDDDD assigns or returns the item "alue ,ith gi"en ke& rom thedi!tionar& o()e!t+e&DDDDDDDDDD sets the ne, ke& "alue or the gi"en ke&0ompare6ode D assigns or returns the !omparison mode or !omparingstring ke&s in a i!tionar& o()e!t.
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 25/40
© 2015 Incessant Technologies
E3A6#4E
(xample ith %ictionary ob'ect in 2TP
K!reate ne, di!tionar& o()e!tSet di!tionar&'()e!t : 0reate'()e!t;@S!ripting.i!tionar&@<
Kadd some ke&Ditem pairsdi!tionar&'()e!t.Add @1@ @Sagar@di!tionar&'()e!t.Add @2@ @Amol@di!tionar&'()e!t.Add @%@ @Ganesh@
Kispla& data in the di!tionar&or ea!h k in di!tionar&'()e!t.ke&s
print k @ D @ di!tionar&'()e!t.item;k<
ne$t
KRemo"e the ke&Ditem pair ,ith ke& : 1 rom the di!tionar& o()e!t
di!tionar&'()e!t.Remo"e;@1@<
KRemo"e all ke&Ditem pairs rom the di!tionar& o()e!tdi!tionar&'()e!t.Remo"eAll
KRelease the o()e!tSet di!tionar&'()e!t : nothing
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 26/40
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 27/40
© 2015 Incessant Technologies
SEN +E7S
/T# tool (e!omes dum( and not a(le to identi& orre!ord the ,indo,s (ased appli!ation
7ou !an send an& !hara!ter to appli!ation to perormspe!i9! a!tion i.e - &ou ,ant to !lose the notepad then
&ou !an do it (& sending1. A4TOF and2. 3.Or onl& A4TOF*
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 28/40
© 2015 Incessant Technologies
E3A6#4E
E$ample ,hi!h perorm !losing notepad a!tion usingsendke&s method
::::::::::::::::::::::::::::::
Set BshShell : 0reate'()e!t;PBS!ript.ShellQ<BshShell.Send+e&s PQ,ait %BshShell.Send+e&s P$Q
,ait %Set BshShell : Nothing
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 29/40
© 2015 Incessant Technologies
FEB E3A6#4ES
There are man& (elo, are e, e$amplesName o +e& Argument
A0+S#A0EA0+S#A0ES or +S#
REA+ REA+
0A#S 4'0+ 0A#S4'0+ 0A#S4'0+
E4 or E4ETE E4
'BN ARR'B 'BN
EN EN
ENTER ENTER or
ES0 ES0
B'R+-NG B-T E30E4
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 30/40
© 2015 Incessant Technologies
B'R+-NG B-T E30E4
"reating (xcel 3pplication Ob'ect
im o()E$!elK0reating an Automation '()e!t in E$!el Appli!ation!lass that !an (e used to perorm operation on E$!elFiles
Set o()E$!el:0reate'()e!t;@E$!el.Appli!ation@<
0REATE AN E30E4 F-4E
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 31/40
© 2015 Incessant Technologies
0REATE AN E30E4 F-4E
"reate an (xcel 4le
im o()E$!el
Set o()E$!el:0reate'()e!t;@E$!el.Appli!ation@<
o()E$!el.Visi(le:True KTo make the 'perations "isi(le
o()E$!el.Bork(ooks.Add
o()E$!el.A!ti"eBork(ook.Sa"eAs @0=o!uments andSettings SESAesktoptp.$ls@
o()E$!el./uit
Set o()E$!el:Nothing
ENTER-NG ATA -N A F-4E
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 32/40
© 2015 Incessant Technologies
ENTER-NG ATA -N A F-4E
"hec# existence o$ the 5ile+ I$ exist then (nter some %ata
6I$ not (xist then "reate the 4le an% enter some %ata
im o()E$!el o()Fso File#ath
File#ath:@0=o!uments and Settingsseshaesktoptp.$ls@
Set o()Fso:0reate'()e!t;@S!ripting.FileS&stem'()e!t@<
Set o()E$!el:0reate'()e!t;@E$!el.Appli!ation@<
- o()Fso.FileE$ists;File#ath< Theno()E$!el.Bork(ooks.'pen;File#ath<
o()E$!el.Borksheets;@Sheet1@<.0ells;11<."alue:@/T# Tool@
o()E$!el.A!ti"eBork(ook.Sa"e
o()E$!el.A!ti"eBork(ook.0lose
Else
o()E$!el.Bork(ooks.Add
o()E$!el.Borksheets;@Sheet1@<.0ells;11<.Value:@/T# Tool@
o()E$!el.A!ti"eBork(ook.Sa"eAs;File#ath<
End i
o()E$!el./uit
Set o()E$!el:Nothing
Set o()Fso:Nothing
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 33/40
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 34/40
ATA R-VEN FRA6EB'R+
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 35/40
© 2015 Incessant Technologies
ATA R-VEN FRA6EB'R+
ata ri"en Frame,ork in /T# -n ata ri"enFrame,ork the data is N'T hardD!oded in the tests!ripts. -nstead it is stored in some e$ternal 9les. Thetest s!ript 9rst !onne!ts to the e$ternal data sour!e andthen e$tra!ts the data rom that sour!e. 6ost o the
times e$!el sheets are used to store the data.'ther e$ternal data sour!es that are reuentl& used areW 1. Te$t 9les.
2.364 9les.
%. ata(ases.
*. 0om(ination o more than one e$ternal 9le.
+E7B'R R-VEN FRA6EB'R+
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 36/40
© 2015 Incessant Technologies
+E7B'R R-VEN FRA6EB'R+
+e&,ord ri"en Frame,ork in /T# -n +e&,ord ri"enrame,ork &ou !an !reate "arious ke&,ords andasso!iate a diLerent a!tion or un!tion ,ith ea!h othese ke&,ords.
Then &ou !reate a Fun!tion 4i(rar& that !ontains thelogi! to read the ke&,ords and !all the asso!iateda!tion.
0'6#'NENTS 'F +E7B'R R-VEN FB
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 37/40
© 2015 Incessant Technologies
0'6#'NENTS 'F +E7B'R R-VEN FB
0omponents in +e&,ord ri"en Frame,ork
ata Ta(le or E$!el Sheets ,hi!h !ontains the ke&,ords andthe steps needed to e$e!ute a parti!ular >o, or a!tion.
A Fun!tion 4i(rar& ,hi!h !ontains "arious un!tions that readea!h line rom the e$!el sheet !on"ert it into P/T# reada(leQormat and 9nall& e$e!ute it. For e$ample the un!tion li(rar&,ould read the 9rst line rom the e$!el and !on"ert it as Wro,ser;PTitleQ<.#age;PTitleQ<.Be(Edit;PUserNameQ<.SetPuser1Q
'()e!t Repositor& ma& or ma& not (e used in this rame,ork. 7ou !an use des!ripti"e programming approa!h i &ou ,ant toa"oid using the o()e!t repositor&.
-NTEGRAT-'N 'F /0 AN UFT
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 38/40
© 2015 Incessant Technologies
-NTEGRAT-'N 'F /0 AN UFT
1.Uploading s!ripts
2.Running s!ripts
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 39/40
© 2015 Incessant Technologies
7/23/2019 QTP_Day3
http://slidepdf.com/reader/full/qtpday3 40/40
-n!essant Te!hnologies an N--T Te!hnologies !ompan& is an -S' D 2XCC1 !erti9ed glo(al #6 spe!ialist pro"iding -T
ser"i!es strategi! !onsulting and "erti!al spe!i9! solutions ser"ing !lients spread a!ross USA U+ Australia 0anada-reland and -ndia. Bith a pro"en e$pertise in designing and (uilding !uttingDedge solutions in"ol"ing #6 0R6 0ase6anagement E06 6iddle,are 6o(ile Anal&ti!s and e!isioning -n!essant has de"eloped inno"ati"e goDtoDmarketsolutions le"eraging partnerships ,ith leading #6 platorms pro"iders like #egas&tems Appian and -6. Bith a deepo!us on FS- Go"ernment ealth!are Retail and Energ& Utilities -n!essant empo,ers organiJations to e$!eed(usiness out!omes. Re!entl& -n!essant is ranked in the Y2C 6ost #romising anking Te!hnolog& Solution #ro"idersD2C15H (& 0-' Re"ie, and YTop 1C 6ost #romising Ser"i!es 0ompanies in -ndiaH (& Sili!on -ndia ;US Edition<. For moreinormation log on to ,,,.in!essantte!hnologies.!om
Thank 7ou