diff options
author | Tulio Casagrande <tcasagra@thoughtworks.com> | 2016-11-29 20:01:53 -0200 |
---|---|---|
committer | Tulio Casagrande <tcasagra@thoughtworks.com> | 2016-11-29 20:05:47 -0200 |
commit | cb95c9442032fc04f4530f2690f22611445c7565 (patch) | |
tree | 8e8eec8d8f9ed95ad3cfe94ac8c82f43b1b446b8 /service/test/functional/features | |
parent | b07f0748a4cff3a3310327a9182d9458d0983613 (diff) |
Improve atomicity of checkbox operations
We were getting too much errors like "Element is no longer attached to
the DOM".
See: https://github.com/pixelated/project-issues/issues/381
Diffstat (limited to 'service/test/functional/features')
-rw-r--r-- | service/test/functional/features/steps/mail_list.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/service/test/functional/features/steps/mail_list.py b/service/test/functional/features/steps/mail_list.py index 7c880e8f..23724bf2 100644 --- a/service/test/functional/features/steps/mail_list.py +++ b/service/test/functional/features/steps/mail_list.py @@ -22,6 +22,7 @@ from common import ( ImplicitWait, execute_ignoring_staleness, find_element_by_id, + find_element_by_css_selector, mail_list_with_subject_exists, wait_for_condition, wait_for_loading_to_finish, @@ -90,31 +91,28 @@ def impl(context): @given('I have mails') @then(u'I have mails') def impl(context): - emails = wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, '.mail-list-entry__item')) + emails = wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, '.mail-list-entry')) assert len(emails) > 0 @when('I mark the first unread email as read') def impl(context): - emails = wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, '.mail-list-entry')) + mail_id = find_element_by_css_selector( + context, '.mail-list-entry:not(.status-read)').get_attribute('id') + + find_element_by_css_selector(context, '#%s input' % mail_id).click() + find_element_by_id(context, 'mark-selected-as-read').click() - for email in emails: - if 'status-read' not in email.get_attribute('class'): - context.current_mail_id = email.get_attribute('id') # we need to get the mail id before manipulating the page - email.find_element_by_tag_name('input').click() - find_element_by_id(context, 'mark-selected-as-read').click() - break - wait_until_elements_are_visible_by_locator(context, (By.CSS_SELECTOR, '#%s.status-read' % context.current_mail_id)) + find_element_by_css_selector(context, '#%s.status-read' % mail_id) @when('I delete the email') def impl(context): - def last_email(): - return wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, '.mail-list-entry')) - mail = last_email() - context.current_mail_id = mail.get_attribute('id') - mail.find_element_by_tag_name('input').click() + mail_id = find_element_by_css_selector(context, '.mail-list-entry').get_attribute('id') + + find_element_by_css_selector(context, '#%s input' % mail_id).click() find_element_by_id(context, 'delete-selected').click() + _wait_for_mail_list_to_be_empty(context) |