Automate your browser with 5 simple steps with Python and Selenium
Normally non-technical people in corporations are forced to do the jobs consisting of boring and repeating processes. However with the era of computer programming, Automating such tasks has been a fancy as well as useful thing (not all the time, Lol). While taking that into context, we know that web browser is very common thing used by almost every computer user So today we will see how we can automate the processes in our browser within few simple steps.
Technologies and Tools we will use in this exercise:
1- Python
For installation instructions, click here.
2- Selenium and Web driver
For installation instruction, click here.
Now we will write a python program to see how we can automate the login process of Yahoo.
Step 1:
Firstly, import the web driver which is nothing but driver provided by selenium to help us navigate the browser automatically.

Step 2:
Set the options for selenium to use through which we will specify what browser we will use, in our case it’s Google chrome.

Make sure to replace the ‘os.path.join ( )’ part with the path of chrome driver which you downloaded while installing and setting up selenium.
Step 3:
Open the initial page you want to begin automation from, in our case it’s Yahoo’s Log in page.

Step 4:
Go to login page -> Right click on username input field -> Click inspect -> Right click on highlighted part on right side of the browser -> Copy -> Copy full Xpath.

then use it in your python code like this:

Now as we have put the username data in respective field successfully. Let’s move to password field by clicking Next button.
Copy the Xpath of Next button in the same way you did for username input field and use it in your code as following:

Note: Repeat the above step for the Password input field and another next button.

Step 5:
Now, you know how to put in text in input fields and click on button in the web page through the automated script. Just execute the script and you will see the browser opening up and loading the Yahoo login page directly with the message that it’s been controlled by some automated driver.
I hope this would be helpful for you, if you have any confusions regarding any step. Please go ahead to ask out in comments, I will try to answer your query.
Till next time, Cheers !!