Created
September 7, 2022 23:33
-
-
Save jin-park/cc00d82634e32261c92d53b17a06136f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
from selenium.webdriver.common.by import By | |
options = webdriver.ChromeOptions() | |
driver = webdriver.Chrome(options=options) | |
student_id = "REPLACE_WITH_STUDENT_ID" | |
name = "REPLACE_WITH_NAME" | |
window_count = 1 | |
while True: | |
if len(driver.window_handles) > window_count: | |
driver.switch_to.window(driver.window_handles[-1]) | |
window_count += 1 | |
url = driver.current_url | |
if "docs.google.com" in url: | |
question_blocks = driver.find_elements(By.CSS_SELECTOR, "div.geS5n") | |
name_student_num = question_blocks[0] | |
form = name_student_num.find_element(By.CSS_SELECTOR, "input.whsOnd.zHQkBf") | |
driver.execute_script("arguments[0].disabled=false", form) | |
form.send_keys(f"{student_id} {name}") | |
gender = question_blocks[1] | |
room = question_blocks[2] | |
gender_options = gender.find_elements(By.CSS_SELECTOR, "div.AB7Lab.Id5V1") | |
driver.execute_script("arguments[0].disabled=false", gender_options[0]) | |
gender_options[0].click() | |
place_options = room.find_elements(By.CSS_SELECTOR, "div.AB7Lab.Id5V1") | |
driver.execute_script("arguments[0].disabled=false", place_options[0]) | |
place_options[0].click() | |
html = driver.find_element(By.TAG_NAME, "html") | |
html.send_keys(Keys.END) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For HAFS students!
INSTRUCTIONS:
place_options
with the one you're trying to reserve (e.g. 0 for the first location on the google form)python automate.py
(this will open chrome)