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

Commit c61ef21

Browse files
Added Automating code for Google with Python - Issue #94
1 parent d56a8c1 commit c61ef21

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe"
3+
}
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("http://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("http://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)

0 commit comments

Comments
 (0)