summaryrefslogtreecommitdiff
path: root/service/test/functional/features/steps/mail_list.py
diff options
context:
space:
mode:
authorTiago Ferraz <tiago.ferraz@gmail.com>2015-03-23 10:27:39 -0300
committerTiago Ferraz <tiago.ferraz@gmail.com>2015-03-26 12:12:40 -0300
commitaab5c4e3f721431591f3709cecb2e2e58ab9774e (patch)
treec9d46bb5378bf77c8b20dcb1adc798e0ce7b5b2c /service/test/functional/features/steps/mail_list.py
parent68a0f94cd15b661caa2b4ea87eef55972c8bff25 (diff)
New test that use checkboxes. Removal of hamcrest lib, code refactoring.
A new test was created to use Pixelated checkboxes and the buttons at the top. Also the lib hamcrest was removed and code refactored to be more pythonic. A new method after_step will log information in case of step failures.
Diffstat (limited to 'service/test/functional/features/steps/mail_list.py')
-rw-r--r--service/test/functional/features/steps/mail_list.py72
1 files changed, 62 insertions, 10 deletions
diff --git a/service/test/functional/features/steps/mail_list.py b/service/test/functional/features/steps/mail_list.py
index 4122f065..74bfe9f2 100644
--- a/service/test/functional/features/steps/mail_list.py
+++ b/service/test/functional/features/steps/mail_list.py
@@ -14,10 +14,13 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from common import *
+from selenium.common.exceptions import NoSuchElementException
+from time import sleep
def find_current_mail(context):
- return find_element_by_xpath(context, '//*[@id="mail-list"]/li[@id="mail-%s"]//a' % context.current_mail_id)
+ return find_element_by_id(context, '%s' % context.current_mail_id)
+
def check_current_mail_is_visible(context):
@@ -25,6 +28,7 @@ def check_current_mail_is_visible(context):
def open_current_mail(context):
+ sleep(2)
e = find_current_mail(context)
e.click()
@@ -37,19 +41,20 @@ def impl(context, tag):
@when('I open that mail')
def impl(context):
- open_current_mail(context)
+ # open_current_mail(context)
+ sleep(3)
+ find_current_mail(context).click()
@when('I open the first mail in the mail list')
def impl(context):
- elements = wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//a'))
- context.current_mail_id = elements[0].get_attribute('href').split('/')[-1]
- elements[0].click()
+ first_email = wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//a'))[0]
+ context.current_mail_id = 'mail-' + first_email.get_attribute('href').split('/')[-1]
+ first_email.click()
@when('I open the first mail in the \'{tag}\'')
def impl(context, tag):
- context.browser.execute_script('window.scrollBy(0, -200)')
context.execute_steps(u"When I select the tag '%s'" % tag)
context.execute_steps(u'When I open the first mail in the mail list')
@@ -62,15 +67,62 @@ def impl(context):
@then('I see the mail I sent')
def impl(context):
src = context.browser.page_source
- assert_that(src, contains_string(context.reply_subject))
+ assert context.reply_subject in src
@then('the deleted mail is there')
def impl(context):
- check_current_mail_is_visible(context)
+ # wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//a'))
+ find_current_mail(context)
@given('I have mails')
def impl(context):
- elements = wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//a'))
- assert len(elements) > 0
+ emails = wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//a'))
+ 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.XPATH, '//*[@id="mail-list"]//li'))
+
+ for email in emails:
+ if 'status-read' not in email.get_attribute('class'):
+ email.find_element_by_tag_name('input').click()
+ find_element_by_id(context, 'mark-selected-as-read').click()
+ context.current_mail_id = email.get_attribute('id')
+ break
+ sleep(2)
+ assert 'status-read' in context.browser.find_element_by_id(context.current_mail_id).get_attribute('class')
+
+
+@when('I delete the email')
+def impl(context):
+ last_email = lambda: wait_until_elements_are_visible_by_locator(context, (By.XPATH, '//*[@id="mail-list"]//li'))[0]
+ context.current_mail_id = last_email().get_attribute('id')
+ last_email().find_element_by_tag_name('input').click()
+ find_element_by_id(context, 'delete-selected').click()
+ assert context.current_mail_id != find_elements_by_xpath(context, '//*[@id="mail-list"]//a')[0]
+
+
+@when('I check all emails')
+def impl(context):
+ find_element_by_id(context, 'toggle-check-all-emails').click()
+
+@when('I delete them permanently')
+def impl(context):
+ find_element_by_id(context, 'delete-selected').click()
+
+@then('I should not see any email')
+def impl(context):
+ try:
+ context.browser.find_element_by_xpath('//*[@id="mail-list"]//a')
+ except NoSuchElementException:
+ assert True
+ except:
+ assert False
+
+
+
+
+