Advertisement
Guest User

Untitled

a guest
Apr 30th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. import datetime
  2. import time
  3. from selenium import webdriver
  4. from selenium.webdriver.common.keys import Keys
  5.  
  6.  
  7.  
  8.  
  9.  
  10. driver = webdriver.Firefox()
  11.  
  12. #Vilken sida drivern ska ta oss till
  13. driver.get("https://se.timeedit.net/web/liu/db1/wr_stud/")
  14.  
  15. #Se till att det står TimeEdit i titeln, för att säkerställa att navigationen har gått rätt till
  16. assert "TimeEdit" in driver.title
  17.  
  18. #Klickar logga in när drivern tagit oss till timeedits-bokningssystem
  19. loginTimeEdit = driver.find_element_by_xpath('/html/body/div[2]/div/table/tbody/tr/td/div/form/div/a[1]')
  20. loginTimeEdit.click()
  21.  
  22. #Fyller i användarnamn på LISAM LIU
  23. #loginLisamUsername = driver.find_element_by_id('userNameInput')
  24. loginLisamUsername = driver.find_element_by_xpath('//*[@id="userNameInput"]')
  25. loginLisamUsername.send_keys("")
  26.  
  27. #Fyller i lösenord på LISAM LIU
  28. #loginLisamPassword = driver.find_element_by_id('passwordInput')
  29. loginLisamPassword = driver.find_element_by_xpath('//*[@id="passwordInput"]')
  30. loginLisamPassword.send_keys("")
  31.  
  32. #Loggar in på LISAM LIU
  33. #loginLisamClick = driver.find_element_by_id('submitButton')
  34. loginLisamClick = driver.find_element_by_xpath('//*[@id="submitButton"]')
  35. loginLisamClick.click()
  36.  
  37. #Väljer studentbokning på LIUS hemsida
  38. chooseStudentBokning = driver.find_element_by_xpath('//*[@id="contents"]/div[3]/div/div[1]/a[1]/div/span[1]/span')
  39. chooseStudentBokning.click()
  40.  
  41. #Behöver en funktion som adderar en dag på den aktuella dagen, och den dagen ska sedan väljas
  42. #de två sista teckena i det nya datumet ska sedan jämföras med Tidsschemat nedanför och sedan välja
  43. #just den spalten. Detta för att sedan trycka på 10-14 i just den dagen och sen klicka okej.
  44.  
  45. tomorrow_date = (datetime.datetime.now() + datetime.timedelta(days=1)) #datetime.datetime
  46. tomorrow_year = str(tomorrow_date.year) #int
  47. tomorrow_month = tomorrow_date.month #int
  48. tomorrow_day = tomorrow_date.day #int
  49. if tomorrow_month < 10:
  50. tomorrow_month = "0"+str(tomorrow_month)
  51. else:
  52. tomorrow_month = str(tomorrow_month)
  53.  
  54. if tomorrow_day < 10:
  55. tomorrow_day = "0"+str(tomorrow_day)
  56. else:
  57. tomorrow_day = str(tomorrow_day)
  58.  
  59. date_button = driver.find_element_by_xpath('//*[@id="leftresdate"]')
  60. date_button.clear()
  61. date_button.click()
  62. date_button.send_keys(str(tomorrow_year) + "-" + str(tomorrow_month) + "-" + str(tomorrow_day))
  63.  
  64. '''
  65. #Visa vilka rum som är tillgängliga (fungerar ej för mig)
  66. chooseOnlyAvailable = driver.find_element_by_xpath('//*[@id="timeHourSpec3"]')
  67. chooseOnlyAvailable.click()
  68.  
  69. #Tar fram tiden 10
  70. chooseStart = driver.find_element_by_xpath('//*[@id="contents"]/div[2]/table/tbody/tr/td[3]/div/select[1]/option[4]')
  71. chooseStart.click()
  72.  
  73. #Tar fram tiden 14
  74. chooseEnd = driver.find_element_by_xpath('//*[@id="contents"]/div[2]/table/tbody/tr/td[4]/div/select[1]/option[8]')
  75. chooseEnd.click()
  76.  
  77. #Trycker på RUM AG21
  78. chooseAG21 = driver.find_element_by_xpath('//*[@id="objectselectionresult"]/table/tbody/tr[2]/td[2]')
  79. chooseAG21.click()
  80. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement