from selenium import webdriver
import time
from datetime import datetime
# twilio to send text message to phone if login succesful
from twilio.rest import Client
from selenium.webdriver.common.action_chains import ActionChains
import keyboard as kb

PATH = "C:\\Program Files (x86)\\chromedriver.exe"
driver = webdriver.Chrome(PATH)
MY_EMAIL =
MY_PASSWORD =
now = datetime.now()
# twilio credential setup
account_sid =
auth_token =
client = Client(account_sid, auth_token)
action = ActionChains(driver)


def login():
# finds the element for the entry bars in google and moves mouse and types credentials
email = driver.find_element_by_id('identifierId')
action.move_to_element(email).perform()
time.sleep(5)
email.click()
kb.write(MY_EMAIL, delay=.1)
emailnext = driver.find_element_by_class_name('VfPpkd-RLmnJb')
action.move_to_element(emailnext).perform()
emailnext.click()
time.sleep(5)

kb.write(MY_PASSWORD, delay=.1)
kb.send('enter')


def fillForm():
# fills google form
textboxes = driver.find_elements_by_class_name(
"quantumWizTextinputPaperinputInput")
radiobuttons = driver.find_elements_by_class_name(
"docssharedWizToggleLabeledLabelWrapper")
reqtext = driver.find_element_by_class_name(
'quantumWizTextinputPapertextareaInput')
submitbutton = driver.find_element_by_class_name(
"appsMaterialWizButtonPaperbuttonContent")

textboxes[0].send_keys('')
textboxes[1].send_keys('')
radiobuttons[0].click()
radiobuttons[6].click()
reqtext.send_keys('')
submitbutton.click()


def logattend():
# text phone
client.messages.create(body=(
f'attended class on {now.strftime("%m/%d/%Y at %I:%M %p")}'), from_='', to='')


def __main__():
print('script will start in 1 min')
time.sleep(60)
driver.get("https://docs.google.com/forms/d/e/1FAIpQLSfAsjDEVFF6DgkyU-iNoHhVPbd5ac7MZVqdYyFqjSjpXigq-g/viewform")
login()
time.sleep(5)
fillForm()
logattend()
driver.quit()


if __name__ == "__main__":
__main__()