From 358faac44b6b3e5820a3acdd927b988f0b1ba313 Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Tue, 14 Oct 2014 13:52:29 +0200 Subject: Tried to make part of functional tests more stable. - Waiting for text change is unreliable, instead wait for Send button to disappear when sending mail --- service/test/functional/features/steps/common.py | 6 ++++-- service/test/functional/features/steps/compose.py | 3 +-- service/test/functional/features/steps/tag_list.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'service/test/functional') diff --git a/service/test/functional/features/steps/common.py b/service/test/functional/features/steps/common.py index 6574d551..4d9ff79c 100644 --- a/service/test/functional/features/steps/common.py +++ b/service/test/functional/features/steps/common.py @@ -24,15 +24,17 @@ def wait_until_element_is_invisible_by_locator(context, locator_tuple): wait = WebDriverWait(context.browser, 10) wait.until(EC.invisibility_of_element_located(locator_tuple)) +def wait_until_element_is_deleted(context, locator_tuple): + wait = WebDriverWait(context.browser, 10) + wait.until(lambda s: len(s.find_elements(locator_tuple[0], locator_tuple[1])) == 0) def wait_for_user_alert_to_disapear(context): wait_until_element_is_invisible_by_locator(context, (By.ID, 'user-alerts')) - def wait_until_element_is_visible_by_locator(context, locator_tuple): wait = WebDriverWait(context.browser, 10) wait.until(EC.visibility_of_element_located(locator_tuple)) - + return context.browser.find_element(locator_tuple[0], locator_tuple[1]) def fill_by_xpath(context, xpath, text): field = context.browser.find_element_by_xpath(xpath) diff --git a/service/test/functional/features/steps/compose.py b/service/test/functional/features/steps/compose.py index 16c909e7..5e323866 100644 --- a/service/test/functional/features/steps/compose.py +++ b/service/test/functional/features/steps/compose.py @@ -68,8 +68,7 @@ def send_impl(context): context.execute_steps(u"when I open the first mail in the mail list") assert_that(is_not(page_has_css(context, '#send-button[disabled]'))) click_button(context, 'Send') - sleep(1) - element_should_have_content(context, '#user-alerts', 'Your message was sent!') + wait_until_element_is_deleted(context, (By.ID, 'send-button')) def _enter_recipient(context, recipients_field, to_type): diff --git a/service/test/functional/features/steps/tag_list.py b/service/test/functional/features/steps/tag_list.py index e83ca2f1..4eee61d1 100644 --- a/service/test/functional/features/steps/tag_list.py +++ b/service/test/functional/features/steps/tag_list.py @@ -30,5 +30,5 @@ def impl(context, tag): wait_for_user_alert_to_disapear(context) click_first_element_with_class(context, 'left-off-canvas-toggle') context.browser.execute_script("window.scrollBy(0, -200)") - e = context.browser.find_element_by_xpath('//*[@id="tag-list"]/ul/li[contains(translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "%s")]' % tag) + e = wait_until_element_is_visible_by_locator(context, (By.XPATH, '//*[@id="tag-list"]/ul/li[contains(translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "%s")]' % tag)) e.click() -- cgit v1.2.3