Skip to content

Commit

Permalink
fixed flaky page layout tests that were broken by long fr_FR strings …
Browse files Browse the repository at this point in the history
…causing UI elements to wrap.
  • Loading branch information
zenmonkeykstop committed Nov 22, 2018
1 parent 1502d91 commit 6c8ae75
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
17 changes: 17 additions & 0 deletions securedrop/tests/functional/functional_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,23 @@ def safe_click_by_id(self, id):

actions = ActionChains(self.driver)
actions.move_to_element(el).perform()

el.click()

def safe_click_by_css_selector(self, selector):
self.wait_for(lambda:
self.driver.find_element_by_css_selector(selector),
timeout=self.sleep_time)

el = self.driver.find_element_by_css_selector(selector)

self.wait_for(lambda: el.is_enabled() and
el.is_displayed,
timeout=self.sleep_time)

actions = ActionChains(self.driver)
actions.move_to_element(el).perform()

el.click()

def _alert_wait(self):
Expand Down
23 changes: 14 additions & 9 deletions securedrop/tests/functional/journalist_navigation_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def doc_selected():
self.wait_for(doc_selected, timeout=self.sleep_time)

def _journalist_clicks_on_modal(self, click_id):
self.driver.find_element_by_id(click_id).click()
# self.driver.find_element_by_id(click_id).click()
self.safe_click_by_id(click_id)
time.sleep(5)

def _journalist_clicks_delete_collections_cancel_on_modal(self):
Expand Down Expand Up @@ -171,16 +172,16 @@ def _journalist_clicks_delete_collection_on_modal(self):
self._journalist_clicks_on_modal('delete-collection-button')

def _journalist_clicks_delete_link(self, click_id, displayed_id):
self.wait_for(lambda: self.driver.find_element_by_id(
click_id).is_enabled(), timeout=self.sleep_time)
self.driver.find_element_by_id(click_id).click()
self.safe_click_by_id(click_id)
self.wait_for(lambda: self.driver.find_element_by_id(displayed_id),
timeout=self.sleep_time)

def _journalist_clicks_delete_selected_link(self):
self._journalist_clicks_delete_link(
'delete-selected-link',
'delete-selected-confirmation-modal')
self.safe_click_by_css_selector(
'a#delete-selected-link > button.danger')
self.wait_for(lambda: self.driver.find_element_by_id(
'delete-selected-confirmation-modal'),
timeout=self.sleep_time)

def _journalist_clicks_delete_collections_link(self):
self._journalist_clicks_delete_link(
Expand Down Expand Up @@ -816,7 +817,10 @@ def _admin_visits_reset_2fa_hotp(self):
'#reset-two-factor-hotp')[0]
assert ('/admin/reset-2fa-hotp' in
hotp_reset_button.get_attribute('action'))
self.wait_for(lambda: hotp_reset_button.is_enabled(),
timeout=self.sleep_time)
hotp_reset_button.click()


def _admin_accepts_2fa_js_alert(self):
self._alert_wait()
Expand Down Expand Up @@ -882,8 +886,9 @@ def _journalist_delete_none(self):
self.driver.find_element_by_id('delete-selected-link').click()

def _journalist_delete_all_confirmation(self):
self.driver.find_element_by_id('select_all').click()
self.driver.find_element_by_id('delete-selected-link').click()
self.safe_click_by_id('select_all')
self.safe_click_by_css_selector(
'a#delete-selected-link > button.danger')

def _journalist_delete_one(self):
self.driver.find_elements_by_name('doc_names_selected')[0].click()
Expand Down

0 comments on commit 6c8ae75

Please sign in to comment.