session.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. '''
  2. title: Automated EPSB check in/out script
  3. author: michael Tang
  4. date created: 2021-01-25
  5. date modified: 2021-02-01
  6. '''
  7. import time
  8. from selenium import webdriver
  9. global URL
  10. global whoHereFor
  11. def checkIn():
  12. ############### Start of check In #################
  13. textboxes = driver.find_elements_by_class_name("quantumWizTextinputPaperinputInput")
  14. textboxes[0].send_keys("Michael Tang")
  15. checkInRadio = driver.find_element_by_css_selector("#i9")
  16. checkInRadio.click()
  17. nextButton = driver.find_element_by_class_name("quantumWizButtonPaperbuttonLabel")
  18. nextButton.click()
  19. time.sleep(2)
  20. # check In
  21. # get textboxes
  22. textboxes2 = driver.find_elements_by_class_name("quantumWizTextinputPaperinputInput")
  23. # get radio buttons
  24. radiobuttons = driver.find_elements_by_class_name("docssharedWizToggleLabeledLabelWrapper")
  25. # get submit button
  26. buttons = driver.find_elements_by_class_name("quantumWizButtonPaperbuttonLabel")
  27. # email [0]
  28. textboxes2[0].send_keys("michael.tang@epsb.ca")
  29. # org [1]
  30. textboxes2[1].send_keys("EPS Supply Services")
  31. # phone number [2]
  32. textboxes2[2].send_keys("7809656618")
  33. # who will you be working with [3]
  34. textboxes2[3].send_keys(whoHereFor)
  35. # click no radio
  36. radiobuttons[0].click()
  37. # click next
  38. buttons[1].click()
  39. ########################## end of Check in ###########################
  40. def checkOut():
  41. ############################ start Check Out ############################
  42. textboxes = driver.find_elements_by_class_name("quantumWizTextinputPaperinputInput")
  43. textboxes[0].send_keys("Michael Tang")
  44. checkOutRadio = driver.find_element_by_css_selector("#i12")
  45. checkOutRadio.click()
  46. nextButton = driver.find_element_by_css_selector(".quantumWizButtonPaperbuttonLabel")
  47. nextButton.click()
  48. time.sleep(3) # wait for next page to load
  49. # Next page of check Out
  50. whoWereYouHereFor = driver.find_element_by_css_selector(".exportTextarea")
  51. whoWereYouHereFor.send_keys(whoHereFor)
  52. ############################ end Check Out ##############################
  53. def locationSelector():
  54. print("Select the school: ")
  55. print("1. ABM")
  56. schoolSelected = input("Select the school: ")
  57. if schoolSelected == "1":
  58. global URL
  59. URL = "https://docs.google.com/forms/d/e/1FAIpQLSeJf3A_bADAUyaXuTEfiyU5O4V77PxcL9lYBSC3vgP4Fn4eGg/viewform"
  60. else:
  61. print("not a valid selection.")
  62. DRIVER_PATH = "/Users/michaeltang/.wdm/drivers/chromedriver/88.0.4324.96/mac64/chromedriver"
  63. # URL = input("Enter the URL: ")
  64. locationSelector()
  65. driver = webdriver.Chrome(DRIVER_PATH)
  66. executor_url = driver.command_executor._url
  67. session_id = driver.session_id
  68. print(session_id)
  69. driver.get(URL)
  70. time.sleep(3)
  71. print("Enter what you want to do: ")
  72. print("1: check in")
  73. print("2. check out")
  74. checkInOut = input("Your selection: ")
  75. # print(checkInOut)
  76. if checkInOut == "1":
  77. print("running check in")
  78. global whoHereFor
  79. whoHereFor = input("Who are you in for: ")
  80. checkIn()
  81. elif checkInOut == "2":
  82. print("running check out")
  83. whoHereFor = input("Who were you in for: ")
  84. checkOut()
  85. else:
  86. print("you did not enter a valid option")