-
Notifications
You must be signed in to change notification settings - Fork 5
/
convo_script.py
139 lines (97 loc) · 3.7 KB
/
convo_script.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# 3rd party libraries
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
import chromedriver_binary
# from chromedriver_py import binary_path
# from service import Service
import traceback
#TODO Change which link you are
is_nav = True
want_email = True
# data files
import excel_reader as er
from NAVids import *
from general_ids import *
# global vars and constants
previous = None
EXTIME = 3
#nav_link = 'https://gatech.co1.qualtrics.com/jfe/form/SV_3R8ddlzjI7zwGEe' # NAV/BSH
# 'https://gatech.co1.qualtrics.com/jfe/form/SV_5dKMXL6Hx1C1tbM' # NAV/BSH SUMMER 23
nav_link = 'https://gatech.co1.qualtrics.com/jfe/form/SV_1YofsnFLCeTX8X4'
#'https://gatech.co1.qualtrics.com/jfe/form/SV_abYKCk3uqiqmRSe' old nav link
east_link = "https://gatech.co1.qualtrics.com/jfe/form/SV_72O9mThAOKPFYeq" # east campus
link = None
if is_nav:
link = nav_link
else:
link = east_link
def next_page():
next_button = WebDriverWait(browser, EXTIME).until(EC.element_to_be_clickable((By.NAME, "NextButton")))
next_button.click()
wait_for_page()
def wait_for_page():
body = WebDriverWait(browser, EXTIME).until(EC.visibility_of_all_elements_located((By.ID, "SurveyEngineBody")))
if previous != None:
wait_stale()
def wait_stale():
global previous
return WebDriverWait(browser, EXTIME).until(EC.staleness_of(previous))
def wait_click(toClick):
global previous
temp = WebDriverWait(browser, EXTIME).until(EC.element_to_be_clickable((By.ID, toClick)))
temp.click()
previous = temp
def wait_type(toTypeTo, message):
global previous
temp = WebDriverWait(browser, EXTIME).until(EC.element_to_be_clickable((By.ID, toTypeTo)))
temp.send_keys(message)
previous = temp
# service_object = Service(binary_path)
# browser = webdriver.Chrome(executable_path=binary_path)
import chromedriver_binary
browser = webdriver.Chrome()
def main():
browser.get(link)
idx = 0
while True:
if (idx >= len(er.RESDIENTS)):
break
try:
wait_for_page()
resident = er.RESDIENTS[idx]
print(resident)
area = wait_click(areas[resident['area']]) # sum 23 removed next_page()
next_page()
ra = wait_click(ras[resident['ra_name']])
if want_email:
email = wait_type(ids['ra_email'], resident['ra_email'])
if is_nav:
next_page()
res_name = wait_type(ids['resident'], resident['name'])
b = wait_click(buildings[resident['building']])
next_page()
f = wait_click(floors[resident['building'] + resident['floor']])
next_page()
print(rooms[resident['building'] + resident['apartment/room']])
r = wait_click(rooms[resident['building'] + resident['apartment/room']])
l = wait_click(letters[resident['bedroom']])
d = wait_type(ids['date'], resident['date'])
meth = wait_click(methods[str(resident['method'])])
topic = wait_click(topics[str(resident['topic'])])
next_page()
if resident['topic'] == 7:
purpose = wait_click(purposes[str(resident['purpose'])])
desc = wait_type(ids['description'], resident['description'])
next_page()
idx+=1
except:
print(traceback.format_exc())
browser.delete_all_cookies()
browser.get(link)
print("Retrying", resident)
browser.quit()
if __name__ == "__main__":
main()
browser.quit()