session.py 3.0 KB

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