| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- '''
- title: Automated EPSB check in/out script
- author: michael Tang
- date created: 2021-01-25
- date modified: 2021-02-07
- '''
- import time
- from selenium import webdriver
- global URL
- global whoHereFor
- # path to chromedriver
- # DRIVER_PATH = "/home/michtang/selenium/chromedriver"
- DRIVER_PATH = "/Users/michaeltang/Documents/selenium/chromedriver_mac"
- driver = webdriver.Chrome(DRIVER_PATH)
- def checkIn():
- ############### Start of check In #################
- textboxes = driver.find_elements_by_class_name("quantumWizTextinputPaperinputInput")
- textboxes[0].send_keys("Michael Tang")
- checkInRadio = driver.find_element_by_css_selector("#i9")
- checkInRadio.click()
- nextButton = driver.find_element_by_class_name("quantumWizButtonPaperbuttonLabel")
- nextButton.click()
- time.sleep(2)
- # check In
- # get textboxes
- textboxes2 = driver.find_elements_by_class_name("quantumWizTextinputPaperinputInput")
- # get radio buttons
- radiobuttons = driver.find_elements_by_class_name("docssharedWizToggleLabeledLabelWrapper")
- # get submit button
- buttons = driver.find_elements_by_class_name("quantumWizButtonPaperbuttonLabel")
- # email [0]
- textboxes2[0].send_keys("michael.tang@epsb.ca")
- # org [1]
- textboxes2[1].send_keys("EPS Supply Services")
- # phone number [2]
- textboxes2[2].send_keys("7809656618")
- # who will you be working with [3]
- textboxes2[3].send_keys(whoHereFor)
- # click no radio
- radiobuttons[0].click()
- # click next
- buttons[1].click()
- print('waiting 2 seconds for final page to load')
- time.sleep(2)
- buttons = driver.find_elements_by_class_name("quantumWizButtonPaperbuttonLabel")
- # find the submit button
- buttonText = buttons[1].text
- pressSubmit = input("Press submit? (y/n)")
- if pressSubmit == "y":
- print(buttons[1].text)
- buttons[1].click()
- time.sleep(1)
- print("quitting")
- driver.quit()
- elif pressSubmit == "n":
- print("Manual mode")
- buttons[0].click()
- else:
- print("invalid key pressed.")
-
- ########################## end of Check in ###########################
- def checkOut():
- ############################ start Check Out ############################
- textboxes = driver.find_elements_by_class_name("quantumWizTextinputPaperinputInput")
- textboxes[0].send_keys("Michael Tang")
- checkOutRadio = driver.find_element_by_css_selector("#i12")
- checkOutRadio.click()
- nextButton = driver.find_element_by_css_selector(".quantumWizButtonPaperbuttonLabel")
- nextButton.click()
- time.sleep(3) # wait for next page to load
- # Next page of check Out
- whoWereYouHereFor = driver.find_element_by_css_selector(".exportTextarea")
- whoWereYouHereFor.send_keys(whoHereFor)
- # Automated click of submit
- buttons = driver.find_elements_by_class_name("quantumWizButtonPaperbuttonLabel")
- # find the submit button
- buttonText = buttons[1].text
- pressSubmit = input("Press submit? (y/n)")
- if pressSubmit == "y":
- print(buttons[1].text)
- buttons[1].click()
- time.sleep(1)
- print("quitting")
- driver.quit()
- elif pressSubmit == "n":
- print("Manual mode")
- buttons[0].click()
- else:
- print("invalid key pressed.")
- ############################ end Check Out ##############################
- def locationSelector():
- print("Select the school: ")
- print("1. ABM")
- print("2. DTK")
- print("3. LOHS")
- print("4. GHL")
- print("5. DDM")
- print("6. McNally")
- schoolSelected = input("Select the school: ")
- if schoolSelected == "1":
- global URL
- URL = "https://docs.google.com/forms/d/e/1FAIpQLSeJf3A_bADAUyaXuTEfiyU5O4V77PxcL9lYBSC3vgP4Fn4eGg/viewform"
- elif schoolSelected == "2":
- URL = "https://docs.google.com/forms/d/e/1FAIpQLSfIZdJoeB8MUrUSAsbKkgsrsRbXB0nUYui2Dn2weCfa5l_KIw/viewform"
- elif schoolSelected == "3":
- URL = "https://docs.google.com/forms/d/e/1FAIpQLSeACzhxKn6mVV0ArePRXE1qz_uojT9CT53OaXnYpEh7T4GzJg/viewform"
- elif schoolSelected == "4":
- URL = "https://docs.google.com/forms/d/e/1FAIpQLSdIT2XbkW4leXrQmS0rEuQ70lZoXkNG_zv7a0JOIRS4wuyxfw/viewform"
- elif schoolSelected == "5":
- URL = "https://docs.google.com/forms/d/e/1FAIpQLSeQJO4uzCHg-OIawaWiVcjJrhcVsFKZ-2hDF4wOaDmz9Xx86w/viewform"
- elif schoolSelected == "6":
- URL = "https://docs.google.com/forms/d/e/1FAIpQLSe8faJgWiVMym4pw6VNR5aJ7j9cJUkP2TYSNUIrYnAcJyaD2w/viewform"
- else:
- print("not a valid selection.")
- locationSelector()
- def main():
- locationSelector()
- # executor_url = driver.command_executor._url
- # session_id = driver.session_id
- # print(session_id)
- driver.get(URL)
- # time.sleep(2)
- print("Enter what you want to do: ")
- print("1: check in")
- print("2. check out")
- checkInOut = input("Your selection: ")
- # print(checkInOut)
- if checkInOut == "1":
- print("running check in")
- global whoHereFor
- whoHereFor = input("Who are you in for: ")
- checkIn()
- elif checkInOut == "2":
- print("running check out")
- whoHereFor = input("Who were you in for: ")
- checkOut()
- else:
- print("you did not enter a valid option")
- main()
- # execute main function
- main()
|