-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstanbic.py
78 lines (61 loc) · 2.54 KB
/
stanbic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from selenium import webdriver
import time
#Set webdriver path
driver = webdriver.Chrome('chromedriver.exe')
#Information about me
gmail = "[email protected]"
gmail_password = '******'
name = "Michael Koranteng"
schoolOfCompletion = "Presbyterian Senior High School, Osu"
address = 'Sowutuom,Accra'
phoneNumber = "0506691160"
comments = "I'm very excited to participate in this!"
#Website to fill forms
url = 'https://docs.google.com/forms/d/1_XyTRmCotkVFmU_V83Mma9uGUMY460CDFEe64-QgYM0/edit'
driver.get(url)
#Set timer to 1 second so we can see the changes
time.sleep(1)
#Access the sign in prompt
sign_in_xpath = driver.find_element_by_xpath(
'/html/body/div[2]/div/div[2]/div[3]/div[2]/span/span')
sign_in_xpath.click()
#Gmail Login
email_id = driver.find_element_by_id('identifierId').send_keys(gmail)
nextbutton_id = driver.find_element_by_id('identifierNext').click()
driver.implicitly_wait(60) # depending on internet speed, we wait for 60 seconds for selenium to find these elements
password = driver.find_element_by_name('password').send_keys(gmail_password)
passwordNextId = driver.find_element_by_id('passwordNext').click()
#details of form
name_xpath = driver.find_element_by_xpath(
'//*[@id="mG61Hd"]/div[2]/div/div[2]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/input'
)
time.sleep(1)
name_xpath.send_keys(name)
radio_gender_id = driver.find_element_by_id('i9').click()
email_xpath = driver.find_element_by_xpath(
'//*[@id="mG61Hd"]/div[2]/div/div[2]/div[3]/div/div/div[2]/div/div[1]/div/div[1]/input'
)
email_xpath.send_keys(gmail)
nextButtonXpath = driver.find_element_by_xpath(
'//*[@id="mG61Hd"]/div[2]/div/div[3]/div[1]/div/div/span')
nextButtonXpath.click()
#Contact Information
school_xpath = driver.find_element_by_xpath(
'//*[@id="mG61Hd"]/div[2]/div/div[2]/div[2]/div/div/div[2]/div/div[1]/div/div[1]/input'
)
time.sleep(1)
school_xpath.send_keys(schoolOfCompletion)
address_xpath = driver.find_element_by_xpath(
'//*[@id="mG61Hd"]/div[2]/div/div[2]/div[3]/div/div/div[2]/div/div[1]/div[2]/textarea'
)
address_xpath.send_keys(address)
phoneNumber_xpath = driver.find_element_by_xpath(
'//*[@id="mG61Hd"]/div[2]/div/div[2]/div[4]/div/div/div[2]/div/div[1]/div/div[1]/input'
)
phoneNumber_xpath.send_keys(phoneNumber)
comments_xpath = driver.find_element_by_xpath(
'//*[@id="mG61Hd"]/div[2]/div/div[2]/div[5]/div/div/div[2]/div/div[1]/div[2]/textarea'
)
comments_xpath.send_keys(comments)
finalSubmitButton = driver.find_element_by_xpath(
'//*[@id="mG61Hd"]/div[2]/div/div[3]/div[1]/div/div[2]/span/span').click()