Web Automation in Python: Sample Project with Source Code.

Hi There.

Today, I am sharing with you a new Sample Python Project that will help beginners boost there programming skills ad understand more concepts.

Selenium Web Automation Sample Project

In this project, we will load Google change the language, then go to google images and search for a keyword entered by the user.

Hre is the source code:

keyword = input("Please Enter a Keyword to Search For:\n") # allow the user to enter a Keyword

from selenium import webdriver # import webdriver from the selenium model

from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_experimental_option('detach', True) 
# Used to keep the browser opened -----------------#

browser = webdriver.Chrome(chrome_options=options)
browser.get('https://www.google.com') # open google.com

# Change Language to english - optional
EnglishCLick = browser.find_element_by_xpath('//*[@id="SIvCob"]/a[1]')

# Open google Images
link = browser.find_element_by_xpath('//*[@id="gbw"]/div/div/div[1]/div[2]/a')

# Search for a Keyword
searchbox = browser.find_element_by_xpath('//*[@id="sbtc"]/div/div[1]/input')


Sharing is caring!

Leave a Comment

Your email address will not be published. Required fields are marked *