Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b720c9bd90
Fetching contributors…

Cannot retrieve contributors at this time

file 60 lines (45 sloc) 2.463 kb
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 52 53 54 55 56 57 58 59 60
#!/usr/bin/env python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from pages.desktop.base import Base
from pages.page import Page


class Contribute(Base):

    def go_to_page(self):
        self.open('/contribute/')

    @property
    def help_form(self):
        return self.HelpForm(self.testsetup)

    class HelpForm(Page):

        _want_to_help_title_locator = (By.CSS_SELECTOR, 'div.row > .form-column-1 > h3')
        _email_field_locator = (By.ID, 'id_email')
        _area_of_interest_locator = (By.ID, 'id_interest')
        _submit_button_locator = (By.ID, 'form-submit')

        _comments_locator = (By.ID, 'id_comments')

        _privacy_checkbox_locator = (By.ID, 'id_privacy')
        _privacy_title_locator = (By.CSS_SELECTOR, '.privacy-check-label span.title')

        _newsletter_checkbox_locator = (By.ID, 'id_newsletter')
        _newsletter_title_locator = (By.CSS_SELECTOR, '.field-newsletter > label')

        _recaptcha_table_locator = (By.ID, 'recaptcha_table')
        _recaptcha_response_field_locator = (By.ID, 'recaptcha_response_field')

        privacy_link = {
            'locator': (By.CSS_SELECTOR, '.privacy-check-label span.title > a'),
            'url_suffix': '/privacy-policy'
        }

        @property
        def elements_are_visible(self):
            return self.is_element_visible(*self._want_to_help_title_locator) and\
                self.is_element_visible(*self._comments_locator) and\
                self.is_element_visible(*self._area_of_interest_locator) and\
                self.is_element_visible(*self._privacy_checkbox_locator) and\
                self.is_element_visible(*self._privacy_title_locator) and\
                self.is_element_visible(*self._newsletter_checkbox_locator) and\
                self.is_element_visible(*self._newsletter_title_locator) and\
                self.is_element_visible(*self._recaptcha_table_locator) and\
                self.is_element_visible(*self._recaptcha_response_field_locator) and\
                self.is_element_visible(*self._submit_button_locator)

        def click_email(self):
            self.selenium.find_element(*self._email_field_locator).click()
            self.wait_for_ajax()
Something went wrong with that request. Please try again.