summaryrefslogtreecommitdiff
path: root/files/puppet/modules/pixelated/files/functional-tests/page_objects/maillist_actions.py
blob: 64c705a52822b9bd80312e43cf4d1927a5af3bd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
# Copyright (c) 2015 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 selenium.webdriver.common.keys import Keys

from base_page_object import BasePageObject


class MailListActions(BasePageObject):
    def __init__(self, context, timeout=10):
        self._locators = {
            'compose_mail_button': 'div#compose-trigger',
            'delete_selected_button': 'input#delete-selected',
            'delete_successful_message': '//span[contains("Your messages were moved to trash!")]',
            'search': '#search-trigger input[type="search"]',
            'select_all_mails': '#toggle-check-all-emails'
        }
        super(MailListActions, self).__init__(context, timeout)

    def open_compose_box(self):
        self._compose_mail_button().click()

    def delete_selected_mails(self):
        self._delete_selected_button().click()

    def select_all_mails(self):
        self._find_element_by_css_locator(self._locators['select_all_mails']).click()

    def do_search(self, search_term):
        search_box = self._find_element_by_css_locator(self._locators['search'])
        search_box.send_keys(search_term + Keys.ENTER)

    def _compose_mail_button(self):
        return self._find_element_by_css_locator(self._locators['compose_mail_button'])

    def _delete_selected_button(self):
        return self._find_element_by_css_locator(self._locators['delete_selected_button'])