-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomate_fill_schedule.py
52 lines (43 loc) · 1.61 KB
/
automate_fill_schedule.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
driver.get("https://www.when2meet.com/?13706256-dnJuv")
assert "When2meet" in driver.title
name = "participant"
password = "password"
# pre-fill first page
elem = driver.find_element_by_id("name")
elem.clear()
elem.send_keys(name)
elem = driver.find_element_by_id("password")
elem.clear()
elem.send_keys("password")
elem.send_keys(Keys.TAB)
elem.send_keys(Keys.ENTER)
button = driver.find_element(By.XPATH, "//input[@value='Sign In']")
# button = driver.find_element_by_xpath("//div[@id='SignIn']/input[1]")
# click(button)
# wait until we're on the schedule-view page
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "YouGridSlots"))
)
except:
driver.quit()
# now we can fill in the schedule based on what we got off Teams or Google calendar
datetime1 = "YouTime1637514000" #dummy data to be replaced
datetime2 = "YouTime1637541900" #more dummy data
source = driver.find_element(By.ID, datetime1)
target = driver.find_element(By.ID, datetime2)
button = driver.find_element(By.ID, datetime1)
driver.implicitly_wait(10)
ActionChains(driver).move_to_element(button).click(button).perform()
actions = ActionChains(driver)
actions.drag_and_drop(source, target)
actions.perform()
assert "No results found." not in driver.page_source
# driver.close()