diff options
| author | Teddy Wing | 2018-02-04 01:57:22 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-02-04 01:57:22 +0100 |
| commit | a53913ac552c1e954b57c9eb66c4c12322b6d880 (patch) | |
| tree | 971d7c48ff5b791a2f5f27f9a6c2dbe5c11f03e7 /harvester_submit_week_for_approval.py | |
| download | harvester-submit-week-for-approval-a53913ac552c1e954b57c9eb66c4c12322b6d880.tar.bz2 | |
Add harvester_submit_week_for_approval.py
The start of a script that will log into Harvest via the normal web
interface and submit the most recent full week's time sheet for
approval.
It uses Selenium and the Firefox WebDriver. It works with the
`-headless` option, but I've commented that out for testing. Right now,
it can open the Harvest sign-in page and log in.
Diffstat (limited to 'harvester_submit_week_for_approval.py')
| -rw-r--r-- | harvester_submit_week_for_approval.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/harvester_submit_week_for_approval.py b/harvester_submit_week_for_approval.py new file mode 100644 index 0000000..1338e2e --- /dev/null +++ b/harvester_submit_week_for_approval.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +from selenium.webdriver import Firefox +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.firefox.options import Options +from selenium.webdriver.support import expected_conditions as expected +from selenium.webdriver.support.wait import WebDriverWait + +email = '' +password = '' +subdomain = '' + +def login(driver): + wait = WebDriverWait(driver, timeout=10) + + driver.get('https://id.getharvest.com/harvest/sign_in') + + wait.until( + expected.visibility_of_element_located((By.NAME, 'email')) + ).send_keys(email) + driver.find_element_by_name('password').send_keys(password + Keys.ENTER) + + return driver + +if __name__ == "__main__": + options = Options() + # options.add_argument('-headless') + driver = Firefox( + executable_path='./geckodriver', + firefox_binary='/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/firefox-bin', + firefox_options=options) + + driver = login(driver) + + print(driver.page_source) + + import time; time.sleep(20) + driver.quit() |
