-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_satchecker.py
186 lines (156 loc) · 8.49 KB
/
test_satchecker.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Generated by Selenium IDE
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import wait
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from selenium.common.exceptions import NoSuchElementException
import smtplib
carriers = {
'att': '@mms.att.net',
'tmobile': ' @tmomail.net',
'verizon': '@vtext.com',
'sprint': '@page.nextel.com'
}
def send(message):
# Replace the number with your own, or consider using an argument\dict for multiple people.
to_number = 'YOUR_PHONE_NUMBER{}'.format(carriers['att'])
auth = ('YOUR_EMAIL', 'EMAIL_PASSWORD')
# Establish a secure session with gmail's outgoing SMTP server using your gmail account
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(auth[0], auth[1])
# Send text message through SMS gateway of destination number
server.sendmail(auth[0], to_number, message)
return
class TestSatchecker():
def setup_method(self):
self.driver = webdriver.Chrome("chromedriver.exe")
self.driver.implicitly_wait(10)
self.vars = {}
self.actions = ActionChains(self.driver)
def teardown_method(self):
self.driver.quit()
def test_satchecker(self):
dateAndLoc = {"November": "", "December": "", "March": ""}
self.driver.get("https://account.collegeboard.org/login/login")
self.driver.set_window_size(1720, 1349)
self.driver.find_element(By.ID, "username").click()
self.driver.find_element(By.ID, "#content").click()
self.driver.find_element(By.ID, "username").send_keys("COLLEGEBOARD_USERNAME")
self.driver.find_element(By.ID, "password").send_keys("COLLEGEBOARD_PASSWORD")
self.driver.find_element(By.ID, "#content").click()
print("logged in")
self.driver.find_element(By.CSS_SELECTOR, ".btn-width-label").click()
self.driver.find_element(By.XPATH, '//*[@id="cb-atlas-header-1"]/div[1]/div/div[2]/div/a[1]').click()
time.sleep(1)
# if security page exists
try:
self.driver.find_element(By.ID, "security")
has_security_page = True
except NoSuchElementException:
has_security_page = False
if has_security_page:
self.driver.find_element(By.ID, "security").click()
self.driver.find_element(By.ID, "security").send_keys("COLLEGEBOARD_PASSWORD")
self.driver.find_element(By.NAME, "verifyPassword").click()
self.driver.find_element(By.CSS_SELECTOR, "li:nth-child(1) .cb-item-title").click()
print("reached landing")
self.driver.find_element(By.ID, "actionRegisterAnother").click()
self.driver.find_element(By.ID, "authenticatePage").click()
self.driver.find_element(By.ID, "gradeLevel").click()
dropdown = self.driver.find_element(By.ID, "gradeLevel")
dropdown.find_element(By.XPATH, "//option[. = '11th grade']").click()
self.driver.find_element(By.ID, "gradeLevel").click()
self.driver.find_element(By.ID, "continue").click()
self.driver.find_element(By.ID, "updateLater").click()
self.driver.find_element(By.ID, "agreeTerms").click()
self.driver.find_element(By.ID, "continue").click()
# self.driver.find_element(By.ID, "feeWaiverNo").click()
# self.driver.find_element(By.ID, "essayAddOnYes").click()
# if len(self.driver.find_elements(By.ID, "optDeclineSAS")) > 0:
# self.driver.find_element(By.ID, "optDeclineSAS").click()
# elif len(self.driver.find_elements(By.ID, "optDeclineQAS")) > 0:
# self.driver.find_element(By.ID, "optDeclineQAS").click()
# self.driver.find_element(By.ID, "continue").click()
# print("reached locations page")
# self.driver.find_element(By.ID, "searchByZipOrCountry").click()
# self.driver.find_element(By.ID, "js-s2-expandTheSearch").click()
# time.sleep(0.5)
# self.driver.find_element(By.ID, "showAvailableOnly").click()
# if self.driver.find_elements(By.XPATH, '//*[@id="testCenterSearchResults"]/tbody/tr')[0].text == "No matching records found":
# print("no dateAndLoc")
# send("nothing yet for " + self.driver.find_element(By.ID, "confirmDateTest").text)
# time.sleep(1.5)
# else:
# print("dateAndLoc found")
# send(str(len(self.driver.find_elements(By.XPATH, '//*[@id="testCenterSearchResults"]/tbody/tr'))) + " dateAndLoc found for " + self.driver.find_element(By.ID, "confirmDateTest").text)
# elements = self.driver.find_elements(By.XPATH, '//*[@id="testCenterSearchResults"]/tbody/tr')
# for i in range(len(elements)):
# send(elements[i].text)
# selectedTestAdminYYYYMM
for month in dateAndLoc:
radioID = ""
month_num = str(time.strptime(month, "%B").tm_mon)
if len(month_num) == 1:
month_num = "0" + month_num
if int(month_num) < 8:
radioID = "selectedTestAdminYYYYMM_" + "2021" + month_num + "2021" + month_num
else:
radioID = "selectedTestAdminYYYYMM_" + "2020" + month_num + "2020" + month_num
print(radioID)
button = self.driver.find_element(By.ID, radioID)
# self.actions.move_to_element(button).perform()
self.driver.execute_script("arguments[0].scrollIntoView();", button)
button.click()
self.driver.find_element(By.ID, "feeWaiverNo").click()
self.driver.find_element(By.ID, "essayAddOnYes").click()
if self.driver.find_elements(By.ID, "optDeclineSAS")[0].is_displayed():
self.driver.find_element(By.ID, "optDeclineSAS").click()
elif self.driver.find_elements(By.ID, "optDeclineQAS")[0].is_displayed():
self.driver.find_element(By.ID, "optDeclineQAS").click()
self.driver.find_element(By.ID, "continue").click()
print("reached locations page")
self.driver.find_element(By.ID, "searchByZipOrCountry").click()
self.driver.find_element(By.ID, "js-s2-expandTheSearch").click()
time.sleep(0.5)
self.driver.find_element(By.ID, "showAvailableOnly").click()
if self.driver.find_elements(By.XPATH, '//*[@id="testCenterSearchResults"]/tbody/tr')[
0].text == "No matching records found":
print("no dates")
dateAndLoc[month] = str(dateAndLoc[month]) + "nothing yet for " + self.driver.find_element(By.ID,
"confirmDateTest").text
time.sleep(1.5)
else:
print("dates found")
dateAndLoc[month] = str(dateAndLoc[month]) + str(
len(self.driver.find_elements(By.XPATH, '//*[@id="testCenterSearchResults"]/tbody/tr'))) + \
" dates found for " + str(
self.driver.find_element(By.ID, "confirmDateTest").text) + "\n"
send(str(len(self.driver.find_elements(By.XPATH,
'//*[@id="testCenterSearchResults"]/tbody/tr'))) + " dates found for " + self.driver.find_element(
By.ID, "confirmDateTest").text)
elements = self.driver.find_elements(By.XPATH, '//*[@id="testCenterSearchResults"]/tbody/tr')
for i in range(len(elements)):
dateAndLoc[month] = dateAndLoc[month] + month + " " + elements[i].text + "\n"
self.driver.find_element(By.XPATH, '//*[@id="js-middle-chooseyourtest&date"]/div[1]/a').click()
time.sleep(5)
self.driver.find_element(By.ID, "cancelBtn").click()
print("cancelled")
time.sleep(5)
# self.driver.find_element(By.XPATH, '//*[starts-with(@id="deleteMyRegistration")]').click()
self.driver.find_element(By.ID, "deleteMyRegistration1").click()
self.driver.switch_to.alert.accept()
print("deleted")
time.sleep(5)
finalstr = ""
for i in dateAndLoc:
finalstr += str(dateAndLoc[i]) + "\n\n"
print(finalstr)
# send("completed the test for SAT")
checker = TestSatchecker()
checker.setup_method()
checker.test_satchecker()
checker.teardown_method()