-
Notifications
You must be signed in to change notification settings - Fork 3
/
bot.py
60 lines (49 loc) · 1.91 KB
/
bot.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
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import Select
import datetime
import os
import sys
usernameStr = 'REPLACE'
passwordStr = 'REPLACE'
try:
usernameStr = sys.argv[1]
passwordStr = sys.argv[2]
except BaseException:
print("\nError: This script should be run with the following (valid) flags:\n python bot.py SIS_Username SIS_Password\n")
sys.exit(-1)
browser = webdriver.Chrome()
browser.get(('https://sis.jhu.edu/sswf/'))
nextButton = browser.find_element_by_id('linkSignIn')
nextButton.click()
username = browser.find_element_by_id('USERdisplay')
username.send_keys(usernameStr)
WebDriverWait(browser, 10)
password = browser.find_element_by_id('PASSWORD')
password.send_keys(passwordStr)
submit1button = browser.find_element_by_id("submit1")
submit1button.click()
WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, "aspnetForm")))
browser.get("https://sis.jhu.edu/sswf/SSS/EnrollmentCart/SSS_EnrollmentCart.aspx?MyIndex=88199")
WebDriverWait(browser, 10)
selectAll = browser.find_element_by_id('SelectAllCheckBox')
selectAll.click()
WebDriverWait(browser, 10)
register = browser.find_element_by_id("ctl00_contentPlaceHolder_ibEnroll")
# # Wait until its 7 O'clock
while True:
current_hour = datetime.datetime.now().time().hour
if current_hour == 7:
browser.execute_script("arguments[0].click();", register)
WebDriverWait(browser, 10000)
while True:
if (browser.find_element_by_id('ctl00_contentPlaceHolder_rbWaitlistYes')):
yes = browser.find_element_by_id('ctl00_contentPlaceHolder_rbWaitlistYes')
cont = browser.find_element_by_id('ctl00_contentPlaceHolder_cmdContinue')
yes.click()
WebDriverWait(browser, 10)
cont.click()
break