diff options
| author | Teddy Wing | 2018-02-04 03:30:43 +0100 |
|---|---|---|
| committer | Teddy Wing | 2018-02-04 03:30:43 +0100 |
| commit | 88cac6b3718e039d0eb88e5c85e566ceb1c704bf (patch) | |
| tree | a1cb43410f29f10687b1d1a5b1150b696afd0bf3 /harvester_submit_week_for_approval.py | |
| parent | 542c25f206c37e6480afbaef7907b3b0955ee189 (diff) | |
| download | harvester-submit-week-for-approval-88cac6b3718e039d0eb88e5c85e566ceb1c704bf.tar.bz2 | |
submit_week_for_approval: Fix page load waiter; Click confirm button
Instead of waiting on an "invisible" `<script>` tag that Selenium
doesn't know how to do, check that the "week" page is loaded a different
way: by checking that the year appears in the header and the day appears
in a column header.
Uncomment the rest of the function.
We weren't clicking the confirmation button (`.approval-confirmation`).
Added a `click()` call there.
Diffstat (limited to 'harvester_submit_week_for_approval.py')
| -rw-r--r-- | harvester_submit_week_for_approval.py | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/harvester_submit_week_for_approval.py b/harvester_submit_week_for_approval.py index 9c92e74..4b2bc6a 100644 --- a/harvester_submit_week_for_approval.py +++ b/harvester_submit_week_for_approval.py @@ -50,32 +50,34 @@ def submit_week_for_approval(driver, wait): driver.get(url) # Wait for page to load - 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')) + wait.until(expected.text_to_be_present_in_element( + (By.CLASS_NAME, 'timesheet-header'), + str(friday.year))) + wait.until(expected.text_to_be_present_in_element( + (By.CSS_SELECTOR, '.day .js-day'), + friday.strftime('%d %b'))) + + # 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', + ) + ) + ).click() + + # 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 - # 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() |
