summaryrefslogtreecommitdiff
path: root/service/test/functional/features/page_objects
diff options
context:
space:
mode:
Diffstat (limited to 'service/test/functional/features/page_objects')
-rw-r--r--service/test/functional/features/page_objects/__init__.py20
-rw-r--r--service/test/functional/features/page_objects/account_recovery_page.py57
-rw-r--r--service/test/functional/features/page_objects/backup_account_page.py30
-rw-r--r--service/test/functional/features/page_objects/base_page.py39
-rw-r--r--service/test/functional/features/page_objects/inbox_page.py52
5 files changed, 198 insertions, 0 deletions
diff --git a/service/test/functional/features/page_objects/__init__.py b/service/test/functional/features/page_objects/__init__.py
new file mode 100644
index 00000000..af50948c
--- /dev/null
+++ b/service/test/functional/features/page_objects/__init__.py
@@ -0,0 +1,20 @@
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+from account_recovery_page import AccountRecoveryPage
+from base_page import BasePage
+from inbox_page import InboxPage
+from backup_account_page import BackupAccountPage
diff --git a/service/test/functional/features/page_objects/account_recovery_page.py b/service/test/functional/features/page_objects/account_recovery_page.py
new file mode 100644
index 00000000..8a4e05cd
--- /dev/null
+++ b/service/test/functional/features/page_objects/account_recovery_page.py
@@ -0,0 +1,57 @@
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+from base_page import BasePage
+
+
+class AccountRecoveryPage(BasePage):
+ def __init__(self, context):
+ super(AccountRecoveryPage, self).__init__(context, context.account_recovery_url)
+
+ self._locators = {
+ 'admin_form': '.account-recovery-form.admin-code',
+ 'admin_code': 'input[name="admin-code"]',
+ 'user_form': '.account-recovery-form.user-code',
+ 'user_code': 'input[name="user-code"]',
+ 'new_password_form': '.account-recovery-form.new-password',
+ 'new_password': 'input[name="new-password"]',
+ 'confirm_password': 'input[name="confirm-password"]',
+ 'submit_button': '.submit-button button[type="submit"]',
+ 'backup_account_link': 'a[href="/backup-account"]'
+ }
+
+ def submit_admin_recovery_code(self, admin_code):
+ self.find_element_by_css_selector(self._locators['admin_form'])
+ self.fill_by_css_selector(self._locators['admin_code'], admin_code)
+ self.click_submit()
+
+ def submit_user_recovery_code(self, user_code):
+ self.find_element_by_css_selector(self._locators['user_form'])
+ self.fill_by_css_selector(self._locators['user_code'], user_code)
+ self.click_submit()
+
+ def submit_new_password(self, new_password, confirm_password):
+ self.find_element_by_css_selector(self._locators['new_password_form'])
+ self.fill_by_css_selector(self._locators['new_password'], new_password)
+ self.fill_by_css_selector(self._locators['confirm_password'], confirm_password)
+ self.click_submit()
+
+ def go_to_backup_account(self):
+ self.find_element_by_css_selector(self._locators['backup_account_link']).click()
+
+ def click_submit(self):
+ submit_button = self.find_element_by_css_selector(self._locators['submit_button'])
+ submit_button.click()
diff --git a/service/test/functional/features/page_objects/backup_account_page.py b/service/test/functional/features/page_objects/backup_account_page.py
new file mode 100644
index 00000000..d5f84b40
--- /dev/null
+++ b/service/test/functional/features/page_objects/backup_account_page.py
@@ -0,0 +1,30 @@
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+from base_page import BasePage
+
+
+class BackupAccountPage(BasePage):
+ def __init__(self, context):
+ super(BackupAccountPage, self).__init__(context, context.backup_account_url)
+
+ self._locators = {
+ 'logout_button': 'button[name="logout"]'
+ }
+
+ def logout(self):
+ logout_button = self.find_element_by_css_selector(self._locators['logout_button'])
+ logout_button.click()
diff --git a/service/test/functional/features/page_objects/base_page.py b/service/test/functional/features/page_objects/base_page.py
new file mode 100644
index 00000000..4756d930
--- /dev/null
+++ b/service/test/functional/features/page_objects/base_page.py
@@ -0,0 +1,39 @@
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+from steps.common import (
+ fill_by_css_selector,
+ find_element_by_css_selector,
+ find_element_by_xpath)
+
+
+class BasePage(object):
+ def __init__(self, context, base_url):
+ self.context = context
+ self.timeout = 30
+ self.base_url = base_url
+
+ def find_element_by_css_selector(self, loc):
+ return find_element_by_css_selector(self.context, loc)
+
+ 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..a6b5fef7
--- /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 <http://www.gnu.org/licenses/>.
+
+from base_page import BasePage
+from steps.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