diff options
| author | Teddy Wing | 2018-02-04 03:21:10 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-02-04 03:21:10 +0100 |
| commit | 542c25f206c37e6480afbaef7907b3b0955ee189 (patch) | |
| tree | 5ec6e38d5729fae4d41fc3a6a46f6ebefd685a8e | |
| parent | 0316618c74b2d15ee31f9a7627aef4c1d44bfd7b (diff) | |
| download | harvester-submit-week-for-approval-542c25f206c37e6480afbaef7907b3b0955ee189.tar.bz2 | |
submit_week_for_approval: Figured out how to get text from `<script>`
Just saving this because it works, which is neat. Unfortunately, I can't
use it in a Selenium wait expectation because it doesn't allow me to
compare arbitrary strings. I have to speak its language, with elements
and contents etc.
This answer showed me how to do this:
https://stackoverflow.com/questions/20497607/how-to-get-the-contents-of-a-script-tag-in-selenium/20498102#20498102
| -rw-r--r-- | harvester_submit_week_for_approval.py | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/harvester_submit_week_for_approval.py b/harvester_submit_week_for_approval.py index 809979b..9c92e74 100644 --- a/harvester_submit_week_for_approval.py +++ b/harvester_submit_week_for_approval.py @@ -50,27 +50,32 @@ def submit_week_for_approval(driver, wait): driver.get(url) # Wait for page to load - wait.until(expected.text_to_be_present_in_element( - (By.ID, 'days-in-week-data-island'), - friday.strftime('%F'))) - - # Click "Submit Week for Approval" button - driver.find_element_by_css_selector( - '.approval-button .submit-link' - ).click() - - # Click "Yes, Submit Timesheet" button - wait.until( - expected.visibility_of_element_located( - ( - By.CSS_SELECTOR, - '.approval-confirmation .js-submit-for-approval', - ))) - - # Wait for success message - wait.until(expected.text_to_be_present_in_element( - (By.ID, 'status_message'), - 'Timesheet has been submitted for approval.')) + print(driver.find_element_by_id('days-in-week-data-island')) + print(driver.find_element_by_id('days-in-week-data-island').get_attribute('innerHTML')) + return driver + # wait.until(expected.text_to_be_present_in_element( + # (By.ID, 'days-in-week-data-island'), + # friday.strftime('%F'))) + + # # Click "Submit Week for Approval" button + # driver.find_element_by_css_selector( + # '.approval-button .submit-link' + # ).click() + # + # # Click "Yes, Submit Timesheet" button + # wait.until( + # expected.visibility_of_element_located( + # ( + # By.CSS_SELECTOR, + # '.approval-confirmation .js-submit-for-approval', + # ))) + # + # # Wait for success message + # wait.until(expected.text_to_be_present_in_element( + # (By.ID, 'status_message'), + # 'Timesheet has been submitted for approval.')) + # + # return driver if __name__ == "__main__": options = Options() |
