- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Google Search Automation with Python Selenium
We can perform Google search automation with Selenium webdriver in Python. First of all, we shall locate the Google search box with the help of any of the locators like id, css, xpath, class, or name.
Then simulate the action of pressing the ENTER key with the help of Keys.ENTER/Keys.RETURN. To perform this operation, we have to use the method send_keys and then pass the parameter – Keys.RETURN /Keys.ENTER. Also, we have to add the statement - from selenium.webdriver.common.keys import Keys to use the Keys class.
Example
from selenium import webdriver from selenium.webdriver.common.keys import Keys import time #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) #launch URL driver.get("https://www.google.com/") #identify search box m = driver.find_element_by_name("q") #enter search text m.send_keys("Tutorialspoint") time.sleep(0.2) #perform Google search with Keys.ENTER m.send_keys(Keys.ENTER)
Output
- Related Articles
- Get Started With Selenium and Python Automation
- Modern Web Automation With Python and Selenium
- How to use Selenium webdriver to click google search?
- Performing Google Search using Python code?
- How to search for a keyword in google using Selenium Java?
- Selenium Web Test Automation Framework Best Practices.
- Why use Selenium WebDriver for Web Automation?
- How to automate google Signup form in Selenium using Python?
- Ok google a google voice search on chrome beta
- What is the difference between selenium and automation?
- How to use Selenium WebDriver for Web Automation?
- A Complete Google Search Console Guide
- Disable images in Selenium Google ChromeDriver.
- How do search engines like Google work?
- Using Extensions with Selenium & Python

Advertisements