From 99125b21697e2a0d9fef5c888e2bbdc33f0adfb2 Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Tue, 11 Apr 2017 19:42:01 -0300 Subject: [#927] Call AccountRecoveryPage parent using the proper way with @deniscostadsc --- .../test/functional/features/page_objects/account_recovery_page.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'service/test/functional/features/page_objects') diff --git a/service/test/functional/features/page_objects/account_recovery_page.py b/service/test/functional/features/page_objects/account_recovery_page.py index 6f502994..4826b6ec 100644 --- a/service/test/functional/features/page_objects/account_recovery_page.py +++ b/service/test/functional/features/page_objects/account_recovery_page.py @@ -19,11 +19,7 @@ from base_page import BasePage class AccountRecoveryPage(BasePage): def __init__(self, context): - BasePage.__init__( - self, - context, - context.account_recovery_url - ) + super(AccountRecoveryPage, self).__init__(context, context.account_recovery_url) self._locators = { 'admin_code': 'input[name="admin-code"]', -- cgit v1.2.3 From cab44227c133af60a31f1988939cbeca5a865efd Mon Sep 17 00:00:00 2001 From: Tulio Casagrande Date: Wed, 12 Apr 2017 17:14:51 -0300 Subject: [#927] Confirm email with the recovery code with @deniscostadsc --- .../functional/features/page_objects/__init__.py | 3 +- .../functional/features/page_objects/base_page.py | 6 ++- .../functional/features/page_objects/inbox_page.py | 52 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 service/test/functional/features/page_objects/inbox_page.py (limited to 'service/test/functional/features/page_objects') diff --git a/service/test/functional/features/page_objects/__init__.py b/service/test/functional/features/page_objects/__init__.py index 6868330b..920bf541 100644 --- a/service/test/functional/features/page_objects/__init__.py +++ b/service/test/functional/features/page_objects/__init__.py @@ -14,5 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . -from base_page import BasePage from account_recovery_page import AccountRecoveryPage +from base_page import BasePage +from inbox_page import InboxPage diff --git a/service/test/functional/features/page_objects/base_page.py b/service/test/functional/features/page_objects/base_page.py index e5fb9a39..4756d930 100644 --- a/service/test/functional/features/page_objects/base_page.py +++ b/service/test/functional/features/page_objects/base_page.py @@ -16,7 +16,8 @@ from steps.common import ( fill_by_css_selector, - find_element_by_css_selector) + find_element_by_css_selector, + find_element_by_xpath) class BasePage(object): @@ -31,5 +32,8 @@ class BasePage(object): def fill_by_css_selector(self, loc, text): fill_by_css_selector(self.context, loc, text) + def find_element_by_xpath(self, xpath): + return find_element_by_xpath(self.context, xpath) + def visit(self): self.context.browser.get(self.base_url) diff --git a/service/test/functional/features/page_objects/inbox_page.py b/service/test/functional/features/page_objects/inbox_page.py new file mode 100644 index 00000000..67ef1375 --- /dev/null +++ b/service/test/functional/features/page_objects/inbox_page.py @@ -0,0 +1,52 @@ +# +# Copyright (c) 2017 ThoughtWorks, Inc. +# +# Pixelated is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pixelated is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Pixelated. If not, see . + +from base_page import BasePage +from common import execute_ignoring_staleness + + +class InboxPage(BasePage): + def __init__(self, context): + super(InboxPage, self).__init__(context, context.inbox_url) + + self._locators = { + 'first_email': '.mail-list-entry__item', + 'read_sandbox': '#read-sandbox', + 'iframe_body': 'body', + } + + def _get_first_mail(self): + return self.find_element_by_css_selector(self._locators['first_email']) + + def get_mail_with_subject(self, subject): + return self.find_element_by_xpath("//*[@class='mail-list-entry__item-subject' and contains(.,'%s')]" % subject) + + def open_first_mail_in_the_mail_list(self): + # it seems page is often still loading so staleness exceptions happen often + self.context.current_mail_id = 'mail-' + execute_ignoring_staleness( + lambda: self._get_first_mail().get_attribute('href').split('/')[-1]) + execute_ignoring_staleness(lambda: self._get_first_mail().click()) + + def open_mail_with_the_recovery_code(self): + self.get_mail_with_subject('Recovery Code').click() + + def get_body_message(self): + self.find_element_by_css_selector(self._locators['read_sandbox']) + self.context.browser.switch_to_frame('read-sandbox') + body_message = self.find_element_by_css_selector(self._locators['iframe_body']).text + self.context.browser.switch_to_default_content() + + return body_message -- cgit v1.2.3