Google Maps Automation Project using Selenium Python.
Hello everyone, this is Hassaan in this article. We are going to learn about how to automate the google maps website using selenium. Let's start Now, first we need to import the required libraries to perform this automation process our requirements are selenium chrome web driver and time library these are the requirements to do this job.
After importing all the requirements you need to create a variable called driver. In this variable you need to give your installation path of chrome web driver. Then you need to get the google maps website. So write driver dot get inside the brackets you need to mention your website name.
So this is the primary step of all selenium automation projects. Next we need to concentrate on searching the places in that google maps website create a function called this place. In this function declare a variable called as place and inside this variable write driver dot find element by class name after this step. We need to open the chrome and search google maps.
Now you can see the google maps website. In this website that is search bar, that is present in the web page. Go to the search bar and right click on that and again press the inspect option. Now you can see all the elements in the google maps. Website for giving the search input through automation process. We need some web elements from the website.
That is the protocol of selenium library now look at the web elements in the website. Here you can see the tactile search box input this is the required web element that we want so copy that element and paste the element in our place variable next we need to send the input word to the website so write place dot send keys inside the brackets you need to mention your destination place and the next step is we need to click the search button to process our input.
Follow the same process that we did in the previous step go to the website and click the search button now inspect the button to fetch the web element and copy the web element by xpath now in the function we need to create variable called as summit and in this variable you need to paste the export value of your element that you copied from the website we successfully did the first part of automation and next we need to give another place to find out the kilometers in between our starting point and destination point additionally.
We are going to find out a few things that is how many hours to reach the destination. What are the possible ways to reach that destination place. So this is the agenda of this article. Let's write a code for this conditions create a function called as directions and in this function you have to declare a variable called as directions inside this variable you need to find a web element so go to the maps website and you can see the directions button inspect the button and copy the xpath value we are going to send a click to the directions button.
So write directions.click and this is enough for this function next create another function that is named as find go to your maps website and you can and now you can see that this website is asking for the starting point. It's a time to give the starting point you need to give the starting point. But not manually we need to give the input through the automations. This is the main role of automations. Go to the search box and inspect the field and copy the web element export value now.
We have the web element value for the search box. Here you need to give another place that is our starting point. Write find dot send keys and inside the brackets. You need to mention your starting point after completing these steps. We have two places the first place that we given that we are given is our destination and second place that we are given is our starting point next we need to process the search by clicking the search button.
So this is the same process that we did in the previous part of automation. So follow my moves carefully after fetching the value of the search button. We need to send a click for that button to process the given search inputs. So write send dot click this is the process of automation and wait our process is not complete. We need to get how many kilometres between. These two places here we can apply the web scraping technique to fetch that results.
Create a function called as kilometres and in this function. You need to put your web element go to the website and you can see how many hours to reach the place by bus and train transport medium. We need these values to print our output screen so follow the same process that we did in the previous step here.
I scrap the data from the google maps website and print those data in my terminal at the end of this script you will notice how cool it is so we finished all the steps go to your terminal and enjoy the automation process of selenium library you.
Google Maps Automation Project using Selenium Python.
Tips and tricks of WhatsApp.
Click here
Google Maps
Click here
I hope you will like it.
Google Maps Automation Project using Selenium Python
If you have any question or doubt please let me know.
If you have any question contact us on our Gmail and by posting the comment.
Our Gmail is mentioned below.
employeesgovernment58@gmail.com
Comments
Post a Comment
Please feel free to contact us.