def search_for_class(self): self.driver.get(self.search_url) self.driver.switch_to.frame( self.driver.find_element_by_name('TargetContent')) select = Select( self.driver.find_element_by_id('CLASS_SRCH_WRK2_STRM$35$')) select.select_by_visible_text('2015 Spring') time.sleep(0.5) self.driver.find_element_by_id('SSR_CLSRCH_WRK_SUBJECT$0').send_keys( self.dept) time.sleep(0.5) self.driver.find_element_by_id( 'SSR_CLSRCH_WRK_SSR_OPEN_ONLY$3').click() time.sleep(0.5) self.driver.find_element_by_id( 'SSR_CLSRCH_WRK_CATALOG_NBR$1').send_keys(self.course_number) #really weird, but in phantomjs, the open class only button is deselected by default, uncomment next line if problems #self.driver.find_element_by_id('SSR_CLSRCH_WRK_SSR_OPEN_ONLY_LBL$3').click() self.driver.find_element_by_name( 'DERIVED_CLSRCH_SSR_EXPAND_COLLAPS$149$$IMG$1').click() self.driver.find_element_by_id('SSR_CLSRCH_WRK_CLASS_NBR$8').send_keys( self.class_number) self.driver.find_element_by_id( 'CLASS_SRCH_WRK2_SSR_PB_CLASS_SRCH').click() time.sleep(0.5) self.driver.save_screenshot('test.jpg') alt_text = self.driver.find_element_by_class_name( 'SSSIMAGECENTER').get_attribute('alt') if (alt_text == 'Open' or alt_text == 'Wait Listed'): robot = RegistryBot(self.username, self.password) robot.login() robot.submit_cart() time.sleep(1) robot.close()
def search_for_class(self): self.driver.get(self.search_url) self.driver.switch_to.frame(self.driver.find_element_by_name('TargetContent')) select = Select(self.driver.find_element_by_id('CLASS_SRCH_WRK2_STRM$35$')) select.select_by_visible_text('2015 Spring') time.sleep(0.5) self.driver.find_element_by_id('SSR_CLSRCH_WRK_SUBJECT$0').send_keys(self.dept) time.sleep(0.5) self.driver.find_element_by_id('SSR_CLSRCH_WRK_SSR_OPEN_ONLY$3').click() time.sleep(0.5) self.driver.find_element_by_id('SSR_CLSRCH_WRK_CATALOG_NBR$1').send_keys(self.course_number) #really weird, but in phantomjs, the open class only button is deselected by default, uncomment next line if problems #self.driver.find_element_by_id('SSR_CLSRCH_WRK_SSR_OPEN_ONLY_LBL$3').click() self.driver.find_element_by_name('DERIVED_CLSRCH_SSR_EXPAND_COLLAPS$149$$IMG$1').click() self.driver.find_element_by_id('SSR_CLSRCH_WRK_CLASS_NBR$8').send_keys(self.class_number) self.driver.find_element_by_id('CLASS_SRCH_WRK2_SSR_PB_CLASS_SRCH').click() time.sleep(0.5) self.driver.save_screenshot('test.jpg') alt_text = self.driver.find_element_by_class_name('SSSIMAGECENTER').get_attribute('alt') if (alt_text == 'Open' or alt_text == 'Wait Listed'): robot = RegistryBot(self.username, self.password) robot.login() robot.submit_cart() time.sleep(1) robot.close()
from class_checker import Class_Checker_Bot from connectcarolina_bot import RegistryBot import cgi ''' #cgi stuff args = cgi.FieldStorage() onyen = args['onyen'] password = args['password'] dept = args['department'] course_number = args['course_number'] class_number = args['class_number'] Class_Checker_Bot(onyen, password, dept, course_number, class_number) ''' userid = raw_input("Onyen: ") pw = raw_input("Password: ") robot = RegistryBot(userid, pw) robot.login()