Skip to content

Instantly share code, notes, and snippets.

@JJGO
Created February 5, 2019 20:22
Show Gist options
  • Save JJGO/e7f1e9fc1d4c4f8758394909a16766b6 to your computer and use it in GitHub Desktop.
Save JJGO/e7f1e9fc1d4c4f8758394909a16766b6 to your computer and use it in GitHub Desktop.
Getfit automation
from selenium.webdriver import Firefox
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options
import time
def getfit_submit(user, pwd, minutes, activity, intensity):
URL = 'https://getfit.mit.edu/user/login?current=team-fitness/home'
options = Options()
options.headless = True
driver = Firefox(options=options)
driver.get(URL)
minutes = str(int(minutes))
def enter(eid, keys):
elem = driver.find_element_by_id(eid)
elem.send_keys(keys)
return elem
e = enter("edit-name", user)
e = enter("edit-pass", pwd)
e.send_keys(Keys.RETURN)
time.sleep(5)
e = enter("duration", minutes)
e = enter("activity-name", activity)
e.send_keys(Keys.RETURN)
e = enter("intensity-tid", intensity)
e = driver.find_element_by_class_name('tf-button')
e.click()
time.sleep(1)
driver.close()
# Credentials
user = 'USER'
pwd = 'GETFIT_PASSWORD'
# Example
getfit_submit(user, pwd, 30, 'Running', 'm')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment