You are on page 1of 16

P

Hoc lo open a
bTOc0seT Y
69 usin9 driver gekuT o7 drivty. navigohe ko teo
OiFfrance betcoeen Web07ivtr 4Wt Element
blesElemen
ltb D7ivEy
O PeFOTm the ackion on O Per Form he achion on elem
ent ohich is PTEsUn an
the bTocOse
kleb Pag9

DiCCs ent meth ods: DiFfren Meihods


O 53eleched ()
9avigake io ) i s dispiay td ()
1sPnableth
O Set Posihion (
Send iceys )

s e Sizeo
maximize y
Click
O clearO
6 9eTlec)
O sekuTenUr| )

9 Closec)
GqukC

evigote t)

OrFfrence be roeen 9er O d NevigakeTo C)

0nly Ooevi gakeTo s also 5Md Lued


get9
method
is ued OcOser
bul eito
bTOco3ey 0 open the
ihe achion ike
+O open
i4 PCrCOYm diFfTn
O navi3ahe- focOCTa
oreaht)
@ navigo be-
O navjalk boCcora9

4gu
colosec)
becoeen
ODrCfrence

uued to close.
etose to clo3e O 9ut
mcnod

cued
is
O closec) mekhod the ai ab5
9 Ho o maximize fhe 6r0cosez ?
6 vng the maximiEe t) mekhed
O4oax

drivt manage 9-taindo coc)


maximi Le tO

Can you
mioimie the br
No, 0e can not ninimize
ocose.1
the brooseY

Componeno seleniom 9
TheYC GT fouT
Compon un 0 selenium
Selenium 119E RC itb07ivey 9Tid

OHoo 0 5eect 2aci and checkbox


69 usi99 Cick mthod coe
tadio buHooi and on
pErfo1mthe qchion 0n

checkbo
Kekurn pe oF 2adio butlon isllebElemen
oyotar
AlesElement tadiodrivtr Find entn (xaath y pan (" ep
tad io: clickc)
To PE Porm di Fvenk acHoo

i s Displyed
isênable.
booleag
1SSdeched Pekn P e

y
9Hoto to oke iK P e t th. tht coeb poge

c 9c the Prom
81 9 3eHTexK\mehod ex

t h e co tb page
Hoo o l the page e
2B3 ing tTHle ) method coe gt the
p01 i}
etun of e 4 shin
Ogntox
sing s divtr geTHe
Sing d 00g)e"
uif (3 equals (d0)
o gs0 Pas3)
elae
J o Fail")

To geTHe)
Sring S t r drivey gekTitle )

Fdd ?
valut 101OPG
OHoco 1o enttT the value

key) 0e enhy the Fitld


- b ingSenq Kpath o
that PrHiculqr
the
1s coe have to 4id
Elemenk
find
15013ployed 15Enabl ed
u55elecked,
Tex,click
94
(Wha stndkey,
ndle, 9t lindo Ho ndl a,
9ekindooHG
SefBiL4 SeH'osiHon
coeb
elcment is
i95eleched)8 the
to veTIY
Mehod used
-155eleched ()
noF dTOpdocwn3 ood
O
sdeched coith
7adio
0uron5,
ustd
-Por o bably ean
veunP
bol
check boxes

is0isployed )- all unds o 0ub


of
Check. uthe Preence
his. method
1ahlC.
Osel Posihion ( 1
eeT
Used O 3t Posiion o brocas

3yoax PoinE
PesrhonP ne co Rasiia ( 1o, 2 0 0 ) i
P'oin
div Se 3TGSTH 095
seleckyVotue, selecg iislelej
islbox, By Index,
3eleei
32 neki ons o
9eAlseleched0phio
2eFOphions, 1SMuliple,
OtiskBK

sel ecB7ndex9- ihe 5peciFTed


ing
ihe ist option3
9sed 4o 3eltch
ind
index SHOTcoith O
pahh(esp9)
3Oa EemenFt69
WebElemen monih driYC Find
(mon h)7
selech 3 neio 3dcc
selecFBind eK G)
S

the 3 epci Pied


ue

e sdtcl BVol uig


1he is Opion
used to seleck
yalue
3kOvCi n swio9
("tAp'"));
S4otax FrodElemen (31 Xpah
monh= driver
VleElemenk
3dcchmenh)E
5tleck s neco
C mere)
Value
S selecFBy

opFion rom h e droP 4oson


uscd to selech the list
Field
Dite
leselement month =Orivtr Find2lemen y-Xpath "txp")
selech m S = neo seec mon th);
S 30ec09VisibleTtxb (3);
geF0ptions t) 6
-Rebuin a option3 belongs o youT seleck 9
Cind the value 1
sequence
eg-cue nave aTTay 0 java 1hn a7Tay di3play
the value Prom index O t0 end oF aTYQy.

s Mulhple ()
Command 15 used to verifg toheBher the speci Pied
selech elemen Suppot Seleciing mulhple option3
a Ahe 3ame me
tekuTn rue cohen uppoth seech ng muu ple.
Opho dse tuuo fail

9eFAIselecded Ophonc)3- h ofiweCltnod


-used to tire all
the. list ophions that 0Te currenH
sdeched in the mulh-sel echion Go fieid

Hoco to ha ndle cxtomiudIis bor


Handletuutomized list boX 4ing theGchion and
e Clags

Achion a 0eco chioo 0;

I s thee an allnate coay to 3endteA9 Dad


tlickC) mehs
For clickt) allernaje 3ubmi
fo1 Sendkeyst) olltnate mttnod Tavo5eeip
OOFfrenl upe or cocut in
sdenium?
hrte ipea of os avka cued in sel enig m
O Tmplicil Naik 8-
coi el o coeb drive10 u b fo a. ctan
Omounl of a ime be CoTe ik throuo3the No 3ucn
elemen excephioo"
iOpplicable. for ol1 the pages / dlenen
Sntax t o i ) Save he decoh) m t

driY maoagec)-tondetotj-bimcouhac) impliciklycOau


o TimeU nik 3econd4 );
Explicil Weut-
L9Pplicd oniy Foy 3pecified elemenks
Ltime tcondihon pa1amehcy ued
tatbdyiy twbdsit fefeuee, TmeQu- l
leiDhit couneas
fluenl Waik -
LT PETFOTm in the lo0p to 3op the time
cued
Ly time, tondikion + trequencyParam ekeu a7

7 pa ofF PoPUPS Hoco to handle ihe


1 Wha 01e he Popup
biocoser pop up 9
Alnl pop up ind thild
toill
seporate coindoco conich
Pop Up a1 the o mall and acio0 on H tiemen

display
ohen y0u Per FOYm thc
ohich are Preuen 0n coeb Page.

4Pes of POP ups -


O Hidden Division Popups
Aler POpUP
Child Oro0sey popup

Authenhicalion Pop Up
file opload
OFile doconlogd
handle alex Pop oP
-

can ook inspech elem en preuen


e 0 Pop
p
-drog aod d rop acFioncan perfo1m
This POpup coill Conhaio
ok," Cancel and
ex
also conkaio Y)+C) 39 mbol

O Cirst toe oced scoikch the selen10m Focuj


io
- From maio pageo aien Pop.up
3Dtax
dTiveT ScoilchTo-0lert ()
tott Foce
AleT Conain sta gbsrach method like
0 HCCepF) To, cliclk.on: ok bukkon
9 dissoisst) To Click on Cancel" buHHOn
g4Test O To gt tex from aler POpup

handlt Child To coseT Pop oP


coe ca perforT9 bath inspec Ond drag t
d10p
operokion
-this Pop Up coill Contain addres Freld
makimize,
minimize close opkion

Haun dle s Oenced 10 SOTch the Sdenigm


COcuu Tom man Page to Child bracose7 Page
Syoiax
driver soikchTo. coindou (sing id)
TF mulhiple child brocaser displayed then to handle
child b7ocOse popup coe need to denhfy addiess Fidd
OYid 0 ids hich io onique
S4Fax
secsing> ids: drive gckai ndoo
Sn n3d ido-Je Cind)j
(9 a ile the code fo01
ScTeensho
drive 3th cococo: google.com");
file souTce = ((TakescreensnoF) driver)- 9ekscreen Shot As

outputfile.File s
File deskinahon neo Pile U" poth of Calder img1-jpg")
FileHondiey-Copy SouTce, destinaBioo

Ho to fehch Ahe daa fom e sxce) sheaE


Firs Coofigure the apache. P01 SaY file in our PoJec
CTeate an exccelsheet Coith same datq 60d SkOTe
i n j conere in any dTive
clus im th
CTcake an objeck oF Jnpulsrea m
exueTnal shee pah a
iopu
Oato
PileLopakSream ile = neo CilelopukStrcam ( pah")
Class Cdthrel
Dah
objttt
- T o open the Cxcel aheek toe need tO 05 3Fohic
mthod ohich p1aent insi de the doovie8 0ok Focioy
cI Cs

Shing valut = took Dook Pachor c cake (Cile) gekshee-

Shee1 gth toco (o) gehcen (o) gelsrioq (ellvalur 0


exe shee S1so (alue);
name
O OPen the speci fic sheet oe need 9elsheel O mcho

To identi toco coe need +o ue gehtoco ) mchod.


To deni te Column oe need Ho use 3chCell )
-To Pekch the shing valuc oc need to e the

9tkSingtallValue t3 mitod
To Pekch the nomeric
valu t e 3c NumeicCd volue 1) oc

be
displayt1 he toebpage au

Ccaus
Hoco 10. handle. Ahe ifiame ? ralo anome C6FaK
2
3 To handle the iramc 0 need to Seleniurm Pou

from main page toTame b iog


drivC Scoikkhlo )-*rameC Srin9, value,inde)
va)ye
Scoikch the rame o 199 pTHCu) gy sring,
and ndex sden
once achon p e i t otm n the ComponenPreen
6st93
0 Qme-Steniom tOi o navi3atc by
dlauu +o au pa9e
coe n c e d
0 Davigale rom irame +o maio
paje
ePaul contai
Use mehod ike patcok rame oy d immidialk pu
div SikhToC) Parco}Gramet)
driver Sajkkh7o () daa auqnkai
n

a n chvld main pci


Poe 4
22 0i0ren AonoBalions and keycoods -
OiCFrenE Annolaions
O 8eforeClass
ed tov executio0 6f Seto est me Hhods beCore eKecuin
es Caas

@ HelClaus
t d fo execuhion oP Peco hes metheds AFhe ezecu-ior
of t4 Cla4s

Beforemekhod
u td Co execution of Peo estmetnod be Core
ececuhion evey tet cbhod

9AFerMehod
bcfore
utd PoY Xeuion a feco test Methods

ake1 execuHon OF eveu tu meod

Tuk OT 1a caue

u t d PoT Xecuhoo o6 ics mehod

takions 8-
oipfrent kegcoord For anno
O PTiOTH= pri0n
mernod oe
ue

10 chcinge the ececuion ineger,


I bydePauu O,Ppas iHive 1okcger negaivC
d uplica
PTigiH Can' be decimal or va Tiable

envocakion
CounF
0 xeCute muliple
-Some ime some mcthod oeed
time then toe utEnvdcatian Counh
Pageo
Dat
natled
TF est class can contoin maliple method and
t
need to skiep one of ut method cxecuHion uoe
0eed +o ueenatled Palse"

TimeOuk
1 classcontain multiple
esk mcth odi
Dne of. the tat memod dime
the TatNG
consuming io execut
bydeCault Pail tha tal meth od and
othtr es meth od cohich
e
Can be uing Time0ur m

depends ON ;-
Tf one eskmthod is depend en the ano ther
then
mu
coe need to use dependi On mtthed koood

Ga3 Which Prameiovk you tuently coo1lein g

Data drive Pramecoork


22 Role ond Respoubliheof 1al engince9
Find 4he locohors
developing Pom elass
Envolve in exeulion

aending the Repork


Diate
Whol a1e the dirfhent Apalih funchions 9

poth Funcions- Hieavt ef rires i o a


Oconlains c)
1ex

Acion and key elaas in sel enium


Achion class abiliy to handle vaviouu 44pt f keqbooed
and mo ue ev en
operaki ong like drag drop 0 (lickiog on mulhple
elements
diffren Puncion in achHion class
ac. move To Elemen ) PCT PoTm(
act clicc t). peuform

Punchiou for k elags


key.ALo-p0- Pa FornmO ei
keH uuD-doun).peorm )

Enie

drop Punckion
drag 4
PrCAent in acionrclass corthPotamchey source 4 duhnakon
2 Whal ove the limilotions of seleni um ond
Coe
in
onich ol
can not ue thegdeum
7 In Selenium c o can no upload
File
and
doconload th
oe cant auo make 1he
caphcha
cant auiomate the bqrcode
ad-hoc tes ca tan' be quomaied

2 Advanfags of Tes+NG 9 7

Abili tO produce HtLRepork ofexecuio0


Annotations a1eqvailabie
Tes caue Ccun be g7ouped or prioribiztd more eo4y
Parallet feain9 Po3sible
GeneLate 1o9 les

exeouke Pail a k taaea

?
Have you Cr Ot cd an1fromecootE it
in
N O i didnt 9t 4chance +o involvc
9
Movan 9 ihal 1s Pom-xm1
2Who s 10ol
ianagmenk
3Movao 5 Frojec
(Mainain ighE
Mavon 15 used 40manage depndancie5
veY3ion G jav5

PoM Projtck Objtck Mod e Fundometal unit of coovk


to Maven, it U an ML e tha con rains the infoYm-
ti deaile
Qhon abou the projcc and conbigura ofii
9.
ulhok is jenkins
Tenkins i3 open Source Continous inlegrahon tool
- T is cTOSS plalform con be used 05 oind ous nux
mac 63

-Jenkins main 4 is to schedule a ptrhculay job and


manikor any j0b. 01 appli colion ohkatus
IFovcs pt-tonbigured achions cahen Perh culo
Shep occus

feauna
IF9enerake al lis of all thanges done in the teposiiey
can bt conCigurE +o
emai
e.can save tesk
tepot and execubio0 hi3hory
O Jeoein3 3upptrs mavan. Por building 00d ieshi 0g 9
Pojec in ci
8 Hoo 1o txecuhe fail tesk coses 9
AFter ton the tes PTojec click on cPresh
A Polde coill be gentraked named iesl-oupuk Polder
Snside sk-oukpul ldtt. 9ou could Cind
iesking-Failed m
Runeshing-Failed xmu ta execuhe he Cailed +eak
Casu again

Ho to gen20 he ihe tepov in you fo meWonk


APher execubian of tesi soript aimpl tefrah me
Projeck it coill awomahically tale the output Poidey
the in ik
and gunezate tapor

9 hal is tesiNG ishene


T is aninBerRace

Th 4 ued t o ciomise teh09 rpel4


she ael
CFail tea ta2 e. SeveEn
OiFtok upe of exceptions io selenium1
OWlt&Drivty Excephion-Ul in no piopn co
OUnseochable b7ocoser excephio0 uhen ot inevupk
67 OCOSe cohile tonning Ihe
e
tesk s0aipk oe tOi 90 Unrcd-
choiit excepion
unHandled ale excephion alel Popup display ond peform
Ahe ackion on brOcOseY
no oltrt prnk excephion coithoul ale pop up toe peFo
on olher pop up
Unexpeched tagName eccepion
Not Connecked exccepti on - cohen selenium 1a7 le onabie
oin b1ao3&Y ihtn oil gch 06l (onnechCd
t o (onnec oe

excepion
O Unsupporked operakion excephion
dement excephon cohen HTIL code to7oung
no such a

to idenh F elemn
becauue of 3ynchronica kion

(3 klhal 1s bject eeposiko1 in.ronlrolized locokion


Used to 3koTe eltmeni locator olud
he axiipk
insted bf hard coding hem coilhin
all the
We do c1eaBe a pToper ile Cprop iha) ipshore 0u 0n objcc
emen locaBois and thue PTOPeTH Filu ack
el oeb-Dsiver
teposilory in selen iom

6Advontages of PoM?
the cod&
mokes eay in maintaunn9
OT
iake Code teadable
1ewa ble
the (od e
Makes ophimised
becomu less and
tode
The
(ohoiFnee bekoten sof o03ev and hovd asser-
Sefy Rssertr
To vercome the drasaback of 0sso cioas ot need t
use o0) asse

sofh aseye coilecis err OYS during eTest


dounok throo an ephoo onen aaseT hre-

Col
Hard RsserE -
T7edudce the lny th of ra Seip de e htl aueu
0LheT do ou so1 4007 a e doka ?
E c c a l ohee

8 ihne de you sto7e 16u7 login tiedinhiols9


opexj 1e.

l h a l is heodless b7o cose


Headiess broco seris a rocsser dimulahion Program tha
dots no have a u5e7 iotr Pa ce
Thae pr0qrams operarc ike an other brocoseybu do no

display an UL
Loltse verst ons of seleniom 9

10 03109
O chTomt
11A 9-9
OHP ALM12-S
selenium tid7ivtY3-14

501 5evvty-20l4
GsORP U1 2-3
0 3RVA o 2
OPoai rion1-7
Eclipse Phskon

You might also like