-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57b40a9
commit 3200c2e
Showing
17 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.pythonPath": "/usr/local/bin/python3" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from webdriver import driver | ||
from cookies import readCookies, writeCookies | ||
from helpers import handleLogin, quitSess | ||
from pages import Home, Student, StudentCenter, EmployeeSelfService | ||
import time, os, sys | ||
|
||
def main_menu(): | ||
while True: | ||
#os.system('cls' if sys.platform == 'win32' else 'clear') | ||
print ("Welcome to WolvTerm 0.0.1!\n") | ||
print ("Please choose the menu you want to start:") | ||
print ("1. Home") | ||
print ("2. Student") | ||
print ("3. Employee Self-Service") | ||
print ("\n0. Quit") | ||
choice = input(">> ") | ||
exec_menu(choice) | ||
return | ||
|
||
def exec_menu(choice): | ||
#os.system('cls' if sys.platform == 'win32' else 'clear') | ||
ch = choice.lower() | ||
if ch == '': | ||
menu_actions['main_menu']() | ||
else: | ||
try: | ||
menu_actions[ch]() | ||
except KeyError: | ||
print ("Invalid selection, please try again.\n") | ||
menu_actions['main_menu']() | ||
return | ||
|
||
def exitSess(): | ||
quitSess() | ||
exit() | ||
|
||
menu_actions = { | ||
'main_menu': main_menu, | ||
'1': Home, | ||
'2': Student, | ||
'3': EmployeeSelfService, | ||
'0': exitSess | ||
} | ||
|
||
if __name__ == "__main__": | ||
Home() | ||
main_menu() | ||
# Home() | ||
#StudentCenter() | ||
# quitSess() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import pickle, getpass | ||
from webdriver import driver | ||
def readCookies(): | ||
if driver.title == '' or driver.title == None: | ||
print("Title is not valid!") | ||
from pages import Home | ||
Home() | ||
|
||
try: | ||
with open('cookies.pkl', 'rb') as j: | ||
cookies = pickle.load(j) | ||
for cookie in cookies: | ||
driver.add_cookie(cookie) | ||
print("Using cookies") | ||
except Exception as e: | ||
print(str(e)) | ||
#print("Continuing without cookies") | ||
from pages import Student | ||
from helpers import enterLogin, navTo, enterTextId, pressEnterId, waitId | ||
print(driver.title) | ||
print("Getting cookies now...") | ||
navTo('https://csprod.dsc.umich.edu/services/student') | ||
print(driver.title) | ||
|
||
if 'Weblogin' in driver.title: | ||
try: | ||
usr = getpass.getpass('Username [Hidden]: ') | ||
password = getpass.getpass('Password [Hidden]: ') | ||
enterTextId('login', usr) | ||
enterTextId('password', password) | ||
pressEnterId('password') | ||
except Exception as e: | ||
print("Oops, something went wrong...") | ||
print(str(e)) | ||
waitId('PT_NAVBAR') | ||
|
||
|
||
|
||
def writeCookies(): | ||
#pickle.dump(driver.get_cookies(), open("cookies.pkl", "wb")) | ||
with open('cookies.pkl', 'wb') as j_out: | ||
pickle.dump(driver.get_cookies(), j_out) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from webdriver import driver | ||
from cookies import readCookies, writeCookies | ||
from selenium.webdriver.common.keys import Keys | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.webdriver.support import expected_conditions as EC | ||
from selenium.webdriver.common.by import By | ||
import getpass | ||
|
||
def enterTextId(id, text): | ||
elem = driver.find_element_by_id(id) | ||
elem.clear() | ||
elem.send_keys(text) | ||
|
||
def pressEnterId(id): | ||
elem = driver.find_element_by_id(id) | ||
elem.send_keys(Keys.RETURN) | ||
|
||
def enterLogin(): | ||
if 'Weblogin' in driver.title: | ||
try: | ||
usr = getpass.getpass('Username [Hidden]: ') | ||
password = getpass.getpass('Password [Hidden]: ') | ||
enterTextId('login', usr) | ||
enterTextId('password', password) | ||
pressEnterId('password') | ||
except Exception as e: | ||
print("Oops, something went wrong...") | ||
print(str(e)) | ||
waitId('PT_NAVBAR') | ||
|
||
def waitId(id): | ||
wait = WebDriverWait(driver, 60) | ||
try: | ||
wait.until(EC.presence_of_element_located((By.ID, id))) | ||
finally: | ||
driver.quit() | ||
|
||
def waitTitle(str): | ||
wait = WebDriverWait(driver, 60) | ||
try: | ||
wait.until(not EC.title_is(str)) | ||
finally: | ||
driver.quit() | ||
|
||
def navTo(url): | ||
driver.get(url) | ||
|
||
def close(): | ||
driver.close() | ||
|
||
def quitSess(): | ||
writeCookies() | ||
driver.close() | ||
driver.quit() | ||
|
||
def handleLogin(func, args=None): | ||
if 'Weblogin' in driver.title: | ||
enterLogin() | ||
waitId('PT_NAVBAR') | ||
#waitTitle('WebLogin') | ||
if args: | ||
func(args) | ||
else: | ||
func() | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from webdriver import driver | ||
from helpers import navTo, handleLogin | ||
|
||
def Home(): | ||
navTo('https://wolverineaccess.umich.edu') | ||
|
||
def Student(): | ||
navTo('https://csprod.dsc.umich.edu/services/student') | ||
|
||
def StudentCenter(): | ||
Student() | ||
driver.execute_script("LaunchURL(this,'https://csprod.dsc.umich.edu/psp/csprodnonop_newwin/EMPLOYEE/SA/c/SA_LEARNER_SERVICES.SSS_STUDENT_CENTER.GBL',0,'bGrouplet@1;','')") | ||
|
||
def EmployeeSelfService(): | ||
navTo('https://hcmprod.dsc.umich.edu/services/employee') |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from cookies import readCookies, writeCookies | ||
from webdriver import driver | ||
from helpers import handleLogin, quitSess | ||
from pages import Home, Student, StudentCenter, EmployeeSelfService | ||
from helpers import navTo | ||
|
||
#cookies = pickle.load(open("cookies.pkl", "rb")) | ||
readCookies() | ||
# Home() | ||
# print(driver.title) | ||
# # Student() | ||
# navTo('https://csprod.dsc.umich.edu/services/student') | ||
# print(driver.title) | ||
# # StudentCenter() | ||
# StudentCenter() | ||
# print(driver.title) | ||
# #assert "No results found." not in driver.page_source | ||
#quitSess() | ||
driver.quit() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from selenium import webdriver | ||
from sys import platform as _platform | ||
import platform | ||
|
||
driver = "" | ||
opts = webdriver.ChromeOptions() | ||
opts.add_argument('headless') | ||
opts.add_argument('remote-debugging-port=9222') | ||
if _platform.startswith("linux"): | ||
driver = webdriver.Chrome(executable_path="webdrivers/chromedriver-linux", options=opts) | ||
elif _platform == "darwin": | ||
driver = webdriver.Chrome(executable_path="webdrivers/chromedriver-mac", options=opts) | ||
elif _platform == "win32" or _platform == "win64": | ||
driver = webdriver.Chrome(executable_path="webdrivers/chromedriver-windows.exe", options=opts) | ||
|
||
# driver.close() |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.