How to click on specific email in gmail using Selenium Webdriver

Sharing buttons:

hello friends so today in this video

I'll be showing you know how you can

click on specific email or into tea men

usually or you know this beginners face

the problem that you know they are

unable to identify the you know the

XPath for specific email because you

know the guy IDs for each of the emails

are different and they keep getting

changed so so you know it's difficult to

you know click on specific email okay so

you know for this tutorial I'll be using

of an extension that is you know crop up

for you know finding the XPath okay so

let's get started so as you can see that

you know there are many number of your

email cell and let's say I wanted to you

know I want selenium to click this

specific email so let's just you know

open the chrome console okay

so as you can see the ID for you know

for this email is this ID for the other

email is this C so you know we cannot

depend on the ID in this case so you

know we have to look to the specific

attributes well you know the values

values are not getting change like see

there are this I I IDs when attribute

closet classes one another table and so

so as you can see that you know this

class attribute is you know same for all

the mail see for this one and for this

one also this one also so you know the

class is common for all the email so you

know by this way I think

you know we can identify the expo so

just on the right but just click on this

crowbar so this is the extension so you

know to find the to find the expert will

be you know creating our own XPath so

this is this index and you know okay

specific attack so on and plus du v OG

and present see

so this pro path will you know identify

all the wave elements which has you know

this class as a be OG so you know so we

we we get the you know list of wave

elements and from which you know we can

select specific you know of a wave

element on which you know we wanted to

we want to click OK this specific image

so let's jump to the you know the

Eclipse part okay so you know I've

already created the project in Eclipse

and you know okay

I've created two plus and I'm you know

for this tutorial I will you know use

the PM object model that's nothing but

the page object model in which you know

we are keeping the the test file in you

know one class and the page objects you

know in the class I hope you know most

of you are aware about the payer pays

object model so I'm just skipping that

part you know and just focusing on how

to click you know email in Gmail okay so

till this part I think most of you

understand that you know I have setup

the chrome driver and and in this part

you know I am going to the Gmail link

okay and in this line I'm initializing

this you know Gmail page object class

which is nothing but this you know

another class where I have started up

the all the you know wave elements I'll

be coming you you know on this on this

class later so this is just move out so

you know I'm initializing this this

class using page factory not in its

elements and you know this is this in

text to you know initialize the page

objects okay so once you know my objects

are initialized it will you know it will

enter the email to logging into Gmail

then it will password and then you know

it will click on this email so I have

created the you know method for this

each action

so let's you know go one by one so this

enter email method this is you know I

have specified in this gmail page of the

X class this is nothing but which we see

you know we just initialize okay so in

this you know first I'm waiting for this

element to be visible so this is another

method which you know I have written see

what this manner will do it will you

know take a wave driver and wave element

as the arguments and you know it will

see this wave driver fade object will

you know wait for this 15 seconds and

till the aluminum

till you know the element is visible so

if the element is visible

you know before 15 seconds and you know

it will identify the element and it will

move out okay so so at this point it

will wait for this email field to appear

which is nothing but the you know

Gmail's first use

name field okay then you know this this

line of code we will you know the what

it will do it will move this you know

the cursor to this email field email

feel you know this this is the you know

babe element which we have specified

here on the top of you know this Gmail

page objects I hope you know many of you

know this how p om you know model works

we are specifying the wave elements at

you know on the top and then you know we

can use that you know any place where

you can oh we need them so you know by

this way it will identify the your

teammates the email field okay so it

will move there it will click and then

you know it will send the email ID you

know which we just have passed yeah so

it will pass this email ID okay and then

this keys dot enter this will you know

this will press enter which we generally

you know place from our keyboard okay so

so what it will do it will enter this

email ID and then it will press enter

and then this action will be performed

so if this exchange perform this you

know this this bring to this message

will be printed okay and then I have

returned this password field so this

it's the same like you know it will

initially wait for this you know this

password field to appear so whenever you

get this password field it will move

ahead to perform this action like it

will move to the password field it will

get there it will send the you know this

password and then it will press enter

and if it's successful it will be

successful then you know it will login

to Gmail


and this flick email function will you

know this will look for this subject in

the into the list of elements a list of

emails sorry so what this function will

do says this is the main part you know

which I think many of you are looking

for so this is the first line of code

will you know wait for the profile logo

because you know I have written the

method of the way like you know it will

it will look for specific wave element

and in this case I am just waiting for

you know these person's profile logo

which is on the you know top right side

of the tree man okay so if you know if

this logo is visible which means that

you know user is logged in into Gmail

okay then I am using this move so this

email threads this is nothing but the

you know this the class Biaggi which you

know I've already told like this class

Bo G contains the list of ill elements

okay so this is the you know our main

list of elements which we need to

perform action ok so so it will

initially get the you know get the size

of number of emails okay and then you

know I am checking like if this email

threats dot get die which means get text

so it's you know the text email subject

message to our email subject which is

nothing but you know whatever we are

passing here like testing and testing

email so I wanted to click this testing

email and which is I'm which is I am

passing here so at this line of code it

will check like from from list of

elements so if it gets this you know

testing email subject then it will click

it will it will pray

in Italy and it will you know break the

loop and it will come out of the loop so

let's you know let's so let's execute it

and let's see how it works

just don't mind okay so it was just

giving me the you know this awesome oh

well you know I haven't specified this

package okay so let's just try to

execute this it opens come down

navigates which email it enters email it

enters possible then it will wait for

that you know profile log of which you

know which email displayed on the right


okay see it clicked it if one so fast

but you know it we found this testing

email with this email subject and you

know it clicked that okay so I hope you

know this video helped you a lot you

know if you got stuck at some point

please let me know in the comments

section thank you