Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 550b652

Browse files
authored
Merge pull request #144 from kritikaparmar-programmer/addingscript
Added Automating code for Google with Python - Issue #94
2 parents b05b6a2 + f3a6215 commit 550b652

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# In this script we will automate Google using Selenium
2+
3+
# Imports :
4+
from selenium import webdriver
5+
from selenium.webdriver.common.keys import Keys
6+
import time
7+
from time import sleep
8+
from webdriver_manager.chrome import ChromeDriverManager
9+
10+
driver = webdriver.Chrome(ChromeDriverManager().install())
11+
12+
# enter the link of the google
13+
driver.get("https://www.google.com")
14+
15+
# AUTOMATING CLICKING OF THE LINK TEXT
16+
17+
# enter the name of the text
18+
element = driver.find_element_by_link_text("About")
19+
20+
# delaying by 2 sec
21+
time.sleep(2)
22+
# clicking of the element is done by the below click method
23+
element.click()
24+
time.sleep(5)
25+
26+
# AUTOMATING CLICKING OF BACKWARD AND FOORWARD BUTTON
27+
28+
# going backward
29+
driver.back()
30+
31+
time.sleep(5)
32+
33+
# going forward
34+
driver.forward()
35+
36+
# AUTOMATING THE REFRESH OF THE WEBPAGE
37+
time.sleep(10)
38+
driver.refresh()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# In this script we will automate Google Search using Selenium
2+
3+
# Imports :
4+
from selenium import webdriver
5+
from selenium.webdriver.common.keys import Keys
6+
import time
7+
from time import sleep
8+
from webdriver_manager.chrome import ChromeDriverManager
9+
10+
11+
driver = webdriver.Chrome(ChromeDriverManager().install())
12+
13+
# providing the link
14+
driver.get("https://www.google.com")
15+
16+
# then we will look for the search bar name(here name is referred to the html code)
17+
element = driver.find_element_by_name("q")
18+
19+
# this is to provide some delay so that we can easily see the process
20+
time.sleep(2)
21+
element.clear()
22+
23+
# here whatever we have to search we can write between the parenthesis
24+
element.send_keys("Python")
25+
26+
# for the enter button
27+
element.send_keys(Keys.RETURN)
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# System-Automation-Scripts
2+
## Automating Google using Selenium
3+
4+
#### Install Requirements :
5+
1. Install Selenium by writing the following pip command, at command prompt -
6+
> pip install selenium
7+
8+
2. Install ChromeDriver
9+
10+
#### Automating_Google_Search.py
11+
- This file contains the script to automate the Google Search , you just have to enter whatever you want to search & run the file.
12+
13+
#### Automating_Google.py
14+
- This file contains the script to automate various tasks on Google like clicking the text link, cliking the forward and the backward button and refreshing of the page .

0 commit comments

Comments
 (0)