Gmail Login | Google Login Using Python Selenium | Google | Gmail Signin Using Python Selenium
Dec 10, 2025
Buy the full source code of application here:
https://buy.stripe.com/9AQ5nEgfLgNi1VebLM
Show More Show Less View Video Transcript
0:01
Uh hello friends, welcome to coding
0:02
sika. So today in this tutorial I will
0:04
be telling you that uh how to use
0:07
selenium in python in order to
0:10
automatically login into your Gmail
0:12
account. So this is the Python script I
0:14
will run here. Let's see the end product
0:18
of this application. So as I run this
0:20
application, you will see a new browser
0:22
window pop. So this will automatically
0:24
enter my email address and password
0:28
and uh then you can see that I am
0:30
successfully logged in onto my Gmail
0:32
account. So this is the overall
0:34
functionality that we will be building
0:36
in this tutorial. So let's start the
0:39
tutorial guys. So this is this tutorial
0:41
will be very interesting. So first of
0:43
all you have to download the Selenium
0:46
Chrome driver onto your local machine.
0:49
So let me just tell you how to do so.
0:52
Just go to Google here and type here uh
0:57
selenium
0:59
chromedriver
1:01
download. Just type this and the first
1:04
result which pops in. Just click this
1:06
result and you can see that there are
1:08
various kinds of download depending upon
1:11
which version of chrome you are using.
1:13
So in order to check what version of
1:15
Chrome you are using you can use the
1:17
site called as um
1:20
uh just write on Google check version of
1:23
Chrome. So the first site which tells
1:26
you just click the site and there is
1:30
alternative site you can see that here
1:32
what is my browser.com. So whenever you
1:35
open this site it will tell you the
1:37
version number I am using Chrome 75.
1:41
So,
1:43
so dependingly
1:45
uh you can see that I'm using Chrome
1:48
version 75. So, just click this. In my
1:52
case, your case will be different. So,
1:54
depending upon your operating system, if
1:56
you're using using Linux, Mac or
1:59
Windows, I'm using Windows. So, I will
2:01
be downloading this zip file. So, I I
2:04
have already downloaded this zip file.
2:06
This after downloading this will the zip
2:09
file. you extract it and then it
2:11
contains the .exe executable file for
2:14
Windows. So just paste this file in the
2:17
working directory of your application.
2:21
So and then you just open the
2:25
uh text editor favorite text editor of
2:28
yours. So let me delete all the code. So
2:32
the first line that you write in your
2:33
Python script is importing the Selenium
2:36
module. So if you haven't downloaded
2:38
this selenium
2:40
module what you can do you can write
2:42
this command pip install selenium. So
2:46
this will actually download selenium
2:48
module in the uh python
2:52
uh directory. So after that from
2:55
selenium module we are importing web
2:57
driver. After that we are making a new
3:00
variable driver and we are using that uh
3:04
chrome driver that we have downloaded
3:06
that is chromedriver.exe.
3:08
So we are importing webdriver dot
3:10
chrome.
3:12
So you can see that
3:14
we are passing the full address. It is
3:16
located in the same directory. So
3:19
nothing here. So after that what we will
3:22
have to do here is that sorry let me
3:25
just delete all the code here and write
3:28
one line at a time. We want to use the
3:31
driver variable and uh invoke this
3:33
function of get and here I will pass the
3:36
full address of Gmail https
3:39
dubdubdubgmail.com.
3:43
So if I execute the script right now and
3:48
you will see that it will automatically
3:50
open gmail.com once I open the script.
3:54
So you can see that it has automatically
3:56
open gmail.com. Now what I want I want
3:59
the XPath address or the name of this.
4:04
So what you can do you can right click
4:06
this Gmail field inspect it
4:10
and click this icon. it will select an
4:14
element in the page to inspect it. Just
4:16
select this and here I want to select
4:18
this element input field. So here we can
4:22
use of this name parameter. You can see
4:24
the name attribute here. So this is a
4:27
value identifier. You just want to copy
4:30
this.
4:31
So this is same for all browsers from
4:35
across the world. So you just have to
4:37
copy this. So this is a unique field by
4:41
which we can target. So driver dot find
4:45
element by name. So you can see that. So
4:48
in that we can just pass the name
4:53
identifier and then we can
4:56
be setting the value. What is the email
4:58
address? You can pass here. I will pass
5:01
uh uh my email address sharma 19987
5:06
do obategmail.com
5:09
that's it after setting the email
5:12
address now let me just run the script
5:14
once again close this
5:18
sorry
5:21
it is running here so just Wait.
5:33
Sorry. Let me run the script again.
5:37
So this will automatically populate this
5:39
Sharma Goautam all this stuff. I don't
5:42
have to write it. So you will see that
5:45
you you you can see that it has
5:47
automatically written this text here. I
5:49
don't have to write on myself. So this
5:53
is the advantage of it. Now I want to
5:55
target the next button here. Similar
5:57
faction I can inspect element and then I
6:00
can click this button and you will be
6:04
redirected to this button.
6:07
This is the sorry let me just select
6:10
this. So you can see that this is the
6:12
next button. So now
6:16
what I want I I need to right click and
6:19
then I want to copy the X path. You can
6:21
see that copy X path. So just copy it.
6:25
After that we will be finding element by
6:28
X path. So there is a function out there
6:31
find element by X path. So in that I
6:34
will be copy pasting the X path.
6:39
So there you need to write it in single
6:41
quotes
6:43
and after that you need to click it
6:45
because this is a button so you need to
6:47
click it. So once again if I run this
6:50
application again
6:53
uh script again
6:56
it will also click the element.
7:00
So
7:04
it is redirected to Gmail. Now it is
7:06
writing the email address. Now it has
7:09
clicked the element. So this is the way
7:11
by which we can see that. Now if I want
7:13
to inspect the password field. So click
7:17
it.
7:20
Now you can see that name attribute. We
7:22
can just target the name also. This is
7:25
password. So we can again but before
7:29
that we have to have some weight. So to
7:32
initialize some weight we can
7:36
uh
7:37
set some implicit weight. So this is a
7:40
function this will wait for some time.
7:42
You can pass here four. So this will
7:45
wait for some time so that Google will
7:47
be manipulated that we are a real weing
7:52
by ourself. So after that we will be
7:56
driver do.findelement
7:58
by class name. So in that we will pass
8:00
here password in order to select the
8:03
password field. Then we will be using
8:05
send keys function. Here I will write my
8:08
password
8:10
Gotham Sharma 123.
8:13
This is my password. Now if I write the
8:16
uh run the
8:19
script here. So what you will see it
8:22
will also populate the password field
8:24
automatically as well. So now it is
8:27
redirected to gmail.com.
8:30
You can see that it has clicked the next
8:32
button. Also
8:36
it has not populated
8:39
the field password.
8:41
So let me just check what has happened.
8:47
Uh
8:59
let me run the script again. Here
9:09
it has it has been redirected to it is
9:12
filling the
9:16
why it is not filling the password
9:18
field. Let me check. Go to this inspect
9:22
element.
9:25
Name is equal to password. This needs to
9:29
Let me just check the code once again.
9:39
Just wait. Let me just check the code
9:41
once again. Why it is why it was not
10:00
This was the overall code here. Find
10:04
element by name password dot send keys
10:07
got sham. Now let me just write uh run
10:10
this script here.
10:13
Let me check.
10:20
Next.
10:24
So now it has populated it the password
10:27
as well. So this is now the last thing
10:32
that remains is is the next button.
10:38
So the next button
10:40
uh which is there here let me just show
10:43
you this is the next button. So for that
10:46
we will be inspecting element here.
10:49
Right click inspect element. Then we
10:51
will click this button.
10:54
In the same fashion we will click this.
10:57
So here copy the X path. So it has
11:01
successfully copied. Now we will write
11:04
driver dotfindelement by X path.
11:10
Here we will pass the X path.
11:15
So this will be
11:18
the X path.
11:22
[snorts] So now if I run
11:25
the script again now it should work.
11:40
Oh sorry I am missing the click
11:42
function. So that is why it was not
11:43
working. So now let me just
11:49
Why two browsers windows are opened? I
11:52
don't know. Now if I run the script, I
11:54
was missing the click function. So that
11:56
is why it was not clicking. So now it
11:59
let me see
12:01
it is making sure. Yes. Yes. Now it is
12:04
not now it is clicking the next element
12:07
as well. So guys we have successfully
12:10
uh opened gmail.com automatically by
12:13
using selenium which is present inside
12:16
python. It is a kind of a module which
12:18
is present.
12:20
So this is uh very much used for automat
12:23
automation testing field. So thanks very
12:26
much guys for watching this video. If
12:28
you like this video then please hit the
12:31
like button. Don't forget to subscribe
12:33
the channel and I will be seeing you in
12:35
the next video. Until then thank you
12:37
very much.
