Created
September 12, 2013 02:50
-
-
Save dbieber/6532578 to your computer and use it in GitHub Desktop.
Course auto-enrollment by Sammy Jerome and myself
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
driver = webdriver.Chrome() | |
driver.set_window_size(1024, 768) # optional | |
url1 = "https://registrar.princeton.edu/score/" | |
url2 = "https://puaccess.princeton.edu/psc/hsprod/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.SSR_SSENRL_CART.GBL?Page=SSR_SSENRL_CART&Action=A&ACAD_CAREER=UGRD&EMPLID=960579807&ENRL_REQUEST_ID=&INSTITUTION=PRINU&STRM=1142" | |
driver.get(url1) | |
raw_input() | |
driver.get(url2) | |
cls = "23410" # COS 402 | |
cls = "20205" # ORF 309 | |
done = False | |
while not done: | |
try: | |
input_field = driver.find_element_by_css_selector("#DERIVED_REGFRM1_CLASS_NBR") | |
input_field.click() | |
input_field.send_keys(cls) | |
print "Class typed" | |
except: | |
pass | |
try: | |
enter = driver.find_element_by_xpath('//*[@id="DERIVED_REGFRM1_SSR_PB_ADDTOLIST2$71$"]') | |
enter.click() | |
time.sleep(.3) | |
print "Enter clicked" | |
except: | |
pass | |
try: | |
next = driver.find_element_by_xpath('//*[@id="DERIVED_CLS_DTL_NEXT_PB$77$"]') | |
next.click() | |
next.click() | |
print "Next clicked" | |
time.sleep(.3) | |
except: | |
pass | |
try: | |
proceed = driver.find_element_by_xpath('//*[@id="DERIVED_REGFRM1_LINK_ADD_ENRL$115$"]') | |
proceed.click() | |
proceed.click() | |
print "Proceed clicked" | |
time.sleep(.4) | |
except: | |
pass | |
try: | |
finish = driver.find_element_by_xpath('//*[@id="DERIVED_REGFRM1_SSR_PB_SUBMIT"]') | |
finish.click() | |
finish.click() | |
print "Finish clicked" | |
time.sleep(.4) | |
except: | |
pass | |
try: | |
addAnother = driver.find_element_by_xpath('//*[@id="DERIVED_REGFRM1_SSR_LINK_STARTOVER"]') | |
addAnother.click() | |
addAnother.click() | |
print "addAnother clicked" | |
time.sleep(.4) | |
except: | |
pass | |
driver.save_screenshot('enrolled.png') | |
time.sleep(3) | |
print "We're done... you should be enrolled in %s" % cls | |
raw_input() | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment