0% ont trouvé ce document utile (0 vote)
22 vues47 pages

Tutoriel Selenium WebDriver FR Simule

Le tutoriel Selenium WebDriver en français est conçu pour les professionnels du test logiciel souhaitant approfondir leurs connaissances en test de front-end avec Selenium en Python. Il couvre divers aspects de l'utilisation de Selenium, y compris l'installation, la navigation dans le navigateur, l'identification d'éléments, et la gestion des attentes. Des exemples pratiques sont fournis pour faciliter l'apprentissage et l'application des concepts abordés.

Transféré par

sahalhassan1994
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
22 vues47 pages

Tutoriel Selenium WebDriver FR Simule

Le tutoriel Selenium WebDriver en français est conçu pour les professionnels du test logiciel souhaitant approfondir leurs connaissances en test de front-end avec Selenium en Python. Il couvre divers aspects de l'utilisation de Selenium, y compris l'installation, la navigation dans le navigateur, l'identification d'éléments, et la gestion des attentes. Des exemples pratiques sont fournis pour faciliter l'apprentissage et l'application des concepts abordés.

Transféré par

sahalhassan1994
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

Page 1
Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

AbouttheTutorial

Sel en i u m Web d ri ver i s a r ob u st t ool f or t e sti ng t h e fr on t en d o f an ap p l i cati on

an d

to

p erf o rm t a sks on t h e b row se r. S el en i u m t ests can b e cr eat ed i n mu l tip l e p rog

ram mi n g

l an gu ag es

l i ke Pyth on , Ja va, an d so on .

Th i s t u t ori al sha l l p rovi d e yo u wi th a d et ai l ed

u n d erstan d i n g on Sel en i u m i n Pyth on l an g u ag e an d i t ssal i en t feat u res .

Public visé

Th i s t u t ori al i s d esi g n ed f or p r of es si on al s worki n g i n softwa r e t es t i n g wh o

Page 2
Tutoriel Selenium WebDriver (Version Française)

wan t t o

i mp rove t h ei r kn o wl ed g e on f r on t en d t e sti n g . Th e t u t ori al con t ai n s a g ood am

ou n t of

h an d s

examp l e on al l i mp ort an t top i cs i n Sel en i u m wi th Pyth on .

Prérequis

Bef or e g o

i n g t h rou g h t h i s t u t ori al , you shou l d have kn owl ed g e on P yth on p rog ram mi n g .

Al so,u n d erstan d i n g soft ware te sti n g i sn eed ed t o st a rt wi t h thi st u t ori al .

Copyright&

Disclaimer

Cop y ri g h t 202

b yTu t ori al sPoi n t (I) Pvt. Ltd .

Al l th e con t en t an d g ra p h i cs

p u bl i shed i n t hi s e

Page 3
Tutoriel Selenium WebDriver (Version Française)

b o ok a re t h e p r op e rt y of Tu t ori al s Poi n t

( I) Pvt. Ltd . Th e u s er of t h i s e

b ook i s p roh i b i t ed t o reu se , r et ai n , cop y, d i stri b u t e or

rep u b l i sh an ycon t en t s or ap a rt of c on t en t s o f t hi se

b o ok i n an yma n n er wi t h ou t wri t t en

con s en t o ft h e

p u b l i sher.

We st ri ve t o u p d at e t h e con t en t s of ou r w eb si t e an d t u t ori al s as ti mely an d as p r

eci sel y

as p o ssi b l e, h owe ve r, t h e c on t en t s ma y con t ai n i n accu raci es o r er r or s . Tu t o ri al

s Poi n t ( I)

Pvt. Ltd . p r ovi d es n o g u aran t ee reg a rd i n g t h e ac curac y, t i meli

n ess o r comp l et en es s of

ou r web si t e o r i t s con t en t s i n cl u di n g t h i s t u t ori al . If you d i scov er a n y e r ro rs

on ou r

web si t e o r i n th i st u t ori al ,pl ease n ot i fy us at

c on t act@t u t ori al spoi n t .com

Page 4
Tutoriel Selenium WebDriver (Version Française)

Page 5
Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

ii

Tableof

Contents

Ab o u t th e Tut o rial

................................

................................

................................

................................

............

Au d ien ce

................................

................................

................................

Page 6
Tutoriel Selenium WebDriver (Version Française)

................................

...........................

Prereq u is ites

................................

................................

................................

................................

.....................

Cop y righ t & Disclai mer

................................

................................

................................

................................

.....

Tab le o f Co n t en ts

Page 7
Tutoriel Selenium WebDriver (Version Française)

................................

................................

................................

................................

............

ii

1.

Se le n iu m We b d

r ive r

In tr o d u c tion

................................

................................

................................

..........

2.

Page 8
Tutoriel Selenium WebDriver (Version Française)

Se le n iu m We b d r ive r

In stal lation

................................

................................

................................

..........

3.

Se le n iu m We b d r ive r

B r o wse r N avigat io n

................................

................................

.............................

4.

Page 9
Tutoriel Selenium WebDriver (Version Française)

Se le n iu m We b d r ive r

Id e n tify Sin g le E le m e n t

................................

................................

........................

By Id

................................

................................

................................

................................

................................

By N ame

................................

Page 10
Tutoriel Selenium WebDriver (Version Française)

................................

................................

................................

..........................

By Clas sN ame

................................

................................

................................

................................

................

11

By TagN ame

................................

................................

................................

................................

...................

12

Page 11
Tutoriel Selenium WebDriver (Version Française)

By L

in k Text

................................

................................

................................

................................

....................

14

By Pa rtia l L in k Text

................................

................................

................................

................................

........

15

By CSS S electo r

................................

................................

Page 12
Tutoriel Selenium WebDriver (Version Française)

................................

................................

..............

17

ByXp at h

................................

................................

................................

................................

.........................

19

5.

Se le n iu m We b d r ive r

Id e n tify M u lt ip le E le m e n ts

................................

................................

................

Page 13
Tutoriel Selenium WebDriver (Version Française)

25

By id

................................

................................

................................

................................

...............................

25

By Clas s n ame

................................

................................

................................

................................

................

25

By Tagn ame

................................

Page 14
Tutoriel Selenium WebDriver (Version Française)

................................

................................

................................

...................

26

By Pa rtia l L in k Text

................................

................................

................................

................................

........

28

By Lin k Text

................................

................................

................................

................................

....................

29

Page 15
Tutoriel Selenium WebDriver (Version Française)

By N ame

................................

................................

................................

................................

........................

31

By CSS S electo r

................................

................................

................................

................................

..............

32

By Xp at h

................................

................................

................................

Page 16
Tutoriel Selenium WebDriver (Version Française)

................................

........................

35

Page 17
Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

iii

6.

Se le n iu m We b d r ive r

Exp lic it an d Im p lic it Wa it

................................

................................

...................

41

E xp licit Wa it

................................

................................

................................

Page 18
Tutoriel Selenium WebDriver (Version Française)

................................

...................

41

Implicit Wa it

................................

................................

................................

................................

..................

43

7.

Se le n iu m We b d r ive r

Pop

ups

................................

................................

Page 19
Tutoriel Selenium WebDriver (Version Française)

................................

.............

45

8.

Se le n iu m We b d r ive r

B ac kw ar d an d Fo r war d N avigatio n

................................

................................

....

47

9.

Se le n iu m We b d r ive r

Co o ki e s

................................

Page 20
Tutoriel Selenium WebDriver (Version Française)

................................

................................

..............

49

10.

Se le n iu m We b d r ive r

Exce p tion s

................................

................................

................................

.........

51

11.

Se le n iu m We b d r ive r

Ac tio n C lass

Page 21
Tutoriel Selenium WebDriver (Version Française)

................................

................................

................................

.......

54

12.

Se le n iu m We b d r ive r

Cr e ate a B asic Te st

................................

................................

.............................

57

13.

Se le n iu m We b d r ive r

Page 22
Tutoriel Selenium WebDriver (Version Française)

Fo r m s

................................

................................

................................

................

59

14.

Se le n iu m We b d r ive r

Dr ag an d Dr o p

................................

................................

................................

...

61

15.

Se le n iu m We b d r ive r

Page 23
Tutoriel Selenium WebDriver (Version Française)

Win d o ws

................................

................................

................................

...........

66

16.

Se le n iu m We b d r ive r

Ale r t s

................................

................................

................................

.................

68

17.

Page 24
Tutoriel Selenium WebDriver (Version Française)

Se le n iu m We b d r ive r

Han d lin g L in ks

................................

................................

................................

...

70

18.

Se le n iu m We b d r ive r

Han d lin g Ed it B o xes

................................

................................

...........................

73

Page 25
Tutoriel Selenium WebDriver (Version Française)

19.

Se le n iu m We b d r ive r

Co lo r Su p p o r t

................................

................................

................................

....

75

20.

Se le n iu m We b d r ive r

Ge n e r ating HTM L Te st R e p o r ts in Pyth o n

................................

..........................

76

Page 26
Tutoriel Selenium WebDriver (Version Française)

21.

Se le n iu m We b d r ive r

R e ad / Wr ite d ata fr o m Exce l

................................

................................

..............

79

22.

Se le n iu m We b d r ive r

Han d lin g C h e c kb o xes

................................

................................

.........................

82

Page 27
Tutoriel Selenium WebDriver (Version Française)

23.

Se le n iu m We b d r ive r

Exec u ting Te sts in M u ltiple B r o wse r s

................................

................................

85

24.

Se le n iu m We b d r ive r

He ad l e ss Exec u tion

................................

................................

............................

89

25.

Page 28
Tutoriel Selenium WebDriver (Version Française)

Se le n iu m We b d r ive r

Wa it Su p p o r t

................................

................................

................................

.....

91

26.

Se le n iu m We b d r ive r

Se le c t Su p p o r t

................................

................................

................................

...

93

Page 29
Tutoriel Selenium WebDriver (Version Française)

27.

Se le n iu m We b d r ive r

Ja vaS c r ip t Exec u to r

................................

................................

............................

96

execu te _ scrip t

................................

................................

................................

................................

...............

97

28.

Page 30
Tutoriel Selenium WebDriver (Version Française)

Se le n iu m We b d r ive r

Ch r o m e We b Dr ive r Op tion s

................................

................................

..............

99

29.

Se le n iu m We b d r ive r

Sc r o ll Op e r ation s

................................

................................

.............................

101

30.

Page 31
Tutoriel Selenium WebDriver (Version Française)

Se le n iu m We b d r ive r

Cap tu r e Sc r e e n sho ts

................................

................................

........................

103

Page 32
Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

iv

31.

Se le n iu m We b d r ive r

R igh t Clic k

................................

................................

................................

........

104

32.

Se le n iu m We b d r ive r

Page 33
Tutoriel Selenium WebDriver (Version Française)

Do u b le C lic k

................................

................................

................................

.....

106

Page 34
Tutoriel Selenium WebDriver (Version Française)

Page 35
Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

Sel en i u m Web d ri ver i s a r ob u st t ool f or t e sti ng t h e fr on t en d o f an ap p l i cati on

an d t o

p erf o rm t a sks on t h e b row se r. S el en i u m t ests can b e cr eat ed i n mu l tip l e p rog

ram mi n g

l an gu ag esl i ke Pyth on ,

J ava,C# ,Ja vaS cri p t ,an d so on .

Sel en i u m wi t h Pyth on c omb i n ati on i s comp arat i vel y ea sy t o u n d er stan d an d i t i

s short i n

ve rb os e. Th e AP Is avai l ab l e i n Pyth on en ab l e us t o c re at e a c on n e cti on wi t h t h e

b row se r

u si n g Sel en i u m.

Sel en i u m p ro vi d es vari ou s Pyth

on c omm an d s wh i ch can b e u s ed fo r cr eat i n g t ests f or

d i fferen t b row s er s l i ke Ch ro me, F i ref ox, IE , an d so on . It c an b e u s ed i n vari ou

p l at forms l i ke Wi n d ows, Mac, Li n u x, an d so on .

Page 36
Tutoriel Selenium WebDriver (Version Française)

Reason s to le arn S elenium w ith P ytho n

Pyth on i seasi e r to l earn an d comp a c

t i n terms o fp r og ram mi n g .

Wh i l e cr eat i n g t ests i n Sel en i u m wi t h Ja va, w e h ave t o t ak e ca re of t h e b eg i n

ni ng

an d en d i n g braces . In P yth on ,si mp l ycod e

i n d e n t ati on

n eed s to b e tak en ca re o f.

Test sd ev el op ed i n Sel en i u m wi th Pyth on ru n fa ster th an th os e w ri t

t en in Java.

Reason s to le arn S elenium Webd ri ver

Th e rea son s to l ea rn Sel en i u m Web d ri ver ar e m en t i on ed bel ow:

Page 37
Tutoriel Selenium WebDriver (Version Française)

It i sop en s ou r ce an d c o mes wi t h ou t an yl i cen sin g cost .

It can p er fo rm mou s e an d keybo ard acti on s l i ke d rag an d d rop , ke y p re ss, cli ck

an d hol d ,a

n d so on .

It ha s av e ry fri en d l yAPI.

It can b e i n t eg rat ed wi t h fram ew or ks l i ke Test NG an d JU n i t , b ui ld t ool s l i ke

Maven , c on t i n u ou si n t eg rat i on tool sl i ke Jen ki n s.

It ha s ah u g e com mu n i tysup p o rt .

It can e xe cut e t est cas e si n headl ess mod e.

Page 38
Tutoriel Selenium WebDriver (Version Française)

1.

SeleniumWebdriver

Introduction

Page 39
Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

Th e i n stal l ati on an d set u p of Sel en i u m web d ri ver i n Pyth on can b e d o n e wi t h t h

e step s

l i sted bel ow:

Step 1

: Navi g at e to th e si t e ha vi n g th e bel ow l i n k:

h t t p s:/ / www .pyth on .o rg / d ow

n l oad s/

Step 2

: Cl i ck on th e D o wn l oad Pyth on <v er si on nu mb er> bu t t on .

Step 3

: Th e e xe cut ab l e fil e fo r P yth on sh ou l d get d o wn l oad ed i n ou r sy stem. On cli cki n

i t ,t h e Pyth on i n stal l ati on pag e sh ou l d get l au n ch ed .

Page 40
Tutoriel Selenium WebDriver (Version Française)

2.

Selenium

Webdriver

Installation

Page 41
Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

Step 4

: Pyth on shou l d be do wn l oad ed i n

t h e fo l l owi n g pat h :

C:

Us er s

< Us er >

Ap pDat a

L oca l

P rog ra ms

Pyt hon

Page 42
Tutoriel Selenium WebDriver (Version Française)

Pyt h on< vers ion >

Step 5

: F or t h e Wi n d ows u s e rs, w e h a ve t o c on fi g u re t h e p at h of t h e Pyth on an d t h

Scri p t sfol d er ( cr eat ed i n si d e th e Pyth on f ol d er) i n th e En vi ron ment va ri ab l es.

Step 6

T o che ck i f P yth on h as succ es sfu l l y i nstal l ed , ex ecut e t h e c o mm an d : p yth on

--

ve rsi on .Th e Pyth on v er si on sh ou l d get di spl ayed .

Step 7

: Fo r th e Sel en i um b i n di n g si n stal l ati on ,ru n th e c omm an d m en t i on ed b el ow:

Page 43
Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

pip install selenium.

Step 8

: A n ew f ol d er c al

l ed t h e Sel eni u m shou l d n ow b e g en erat ed wi t hi n t h e Pyth on

fol d er. To up g rad e to th e l at est S el en i u m ver si on ,ru n th e comm an d gi ven bel ow:

pip install

--

U s e le n iu m .

Step 9

: T o ve ri fy i f Sel en i u m h as b e en i n stal l ed p rop erl y, ex ecu t e t h e c omm an d

ment i on ed bel ow:

pip show Selenium.

Step 10

Page 44
Tutoriel Selenium WebDriver (Version Française)

: N ext, w e h av e t o d own l oad t h e Pyth on ed i t or cal l ed PyCh ar m fr om t h e b el ow

l i n k:

htt

p s:/ / www .jetb rai n s.c om/ p ych a rm/

Step 11

: Cl i ck on Do wn l oad .

Step 1 2

: F o r Sel en i um web d ri ve r i n Pyth on , cl i ck on t h e Down l oa d b u t t on wh i ch i s

b el ow th e C omm u n i t yver si on (fre e fo r us e) .

Page 45
Tutoriel Selenium WebDriver (Version Française)

Sel en i u m Web d ri ver

Step 13

: A fte r i n stal l at i on of P yCh arm , w e h ave t o c reat e a n ew p r o

j ect f rom F i l e

>

New Pr oj e ct

> Gi ve ap roj e ct n am e, say pyth o n Proj e ctT est. Th en , cl i ckon

Cre ate

Step 14

: W e h av e t o c reat e a Pyth on p ac kag e b y ri g h t

cl i cki n g on t he n ew p r oj e ct we

cr eat ed i n St ep 13 , cl i ck on Ne w t h en s el ect Pyt h on Pac kag e . Gi ve a p a ck

ag e n am e , say

Page 46
Tutoriel Selenium WebDriver (Version Française)

Sel en i u mTest an d p ro ce ed .

Step 1 5

: We h ave t o cr eat e a Pyth on fi l e b y ri g h t

cl i cki n g on t h e n ew p ackag e w e

cr eat ed i n St ep 14 , cl i ck on New t h en s el ect Pyth on F i l e. Gi ve a p ackag e n am e ,

say

t est1 .py an d pr oc eed .

Step 16

: T o vi ew t h e Sel

en i u m p ackag e s i n ou r p r oj ect , cl i ck on E xt ern al Li b rari es an d

t h en expa n d th e si t e

p ackag e sf ol d er.

Page 47

Vous aimerez peut-être aussi