How to use the gaiatest.apps.base.PageRegion function in gaiatest

To help you get started, we’ve selected a few gaiatest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla-b2g / gaia / tests / python / gaia-ui-tests / gaiatest / apps / clock / app.py View on Github external
def dismiss_banner(self):
        banner = Wait(self.marionette).until(
            expected.element_present(*self._banner_countdown_notification_locator))
        Wait(self.marionette).until(expected.element_displayed(banner))
        # We can't tap to clear the banner as sometimes it taps the underlying alarm changing the UI
        Wait(self.marionette).until(expected.element_not_displayed(banner))

    def tap_new_alarm(self):
        new_alarm = Wait(self.marionette).until(
            expected.element_present(*self._alarm_create_new_locator))
        Wait(self.marionette).until(expected.element_displayed(new_alarm))
        new_alarm.tap()
        from gaiatest.apps.clock.regions.alarm import NewAlarm
        return NewAlarm(self.marionette)

    class Alarm(PageRegion):

        _label_locator = (By.CSS_SELECTOR, '.label')
        _check_box_locator = (By.CSS_SELECTOR, '.input-enable')
        _enable_button_locator = (By.CSS_SELECTOR, '.alarmList.alarmEnable')
        _time_locator = (By.CSS_SELECTOR, '.time')

        def time(self):
            return self.root_element.find_element(*self._time_locator).text

        @property
        def label(self):
            return self.root_element.find_element(*self._label_locator).text

        @property
        def is_alarm_active(self):
            return self.root_element.find_element(*self._check_box_locator).is_selected()
github mozilla-b2g / gaia / tests / python / gaia-ui-tests / gaiatest / apps / email / regions / settings.py View on Github external
class Settings(Base):
    #general email settings
    _email_account_locator = (By.CSS_SELECTOR, '.tng-account-item')
    _account_add_locator = (By.CLASS_NAME, 'tng-account-add')

    def __init__(self, marionette):
        Base.__init__(self, marionette)
        Wait(self.marionette).until(expected.element_displayed(
            Wait(self.marionette).until(expected.element_present(
                *self._email_account_locator))))

    @property
    def email_accounts(self):
        return [self.Account(self.marionette, email_account) for email_account in self.marionette.find_elements(*self._email_account_locator)]

    class Account(PageRegion):
        _name_locator = (By.CSS_SELECTOR, 'a.tng-account-item-label')

        def tap(self):
            self.root_element.tap()
            return EmailAccountSettings(self.marionette)

        def a11y_click(self):
            self.accessibility.click(self.root_element)
            return EmailAccountSettings(self.marionette)


class EmailAccountSettings(Base):
    #settings for a specific email account

    _delete_account_locator = (By.CSS_SELECTOR, '.tng-account-delete')
github mozilla-b2g / gaia / tests / python / gaia-ui-tests / gaiatest / apps / messages / regions / message_thread.py View on Github external
self.marionette.find_element(*self._message_header_locator).tap()

        from gaiatest.apps.messages.regions.activities import Activities
        return Activities(self.marionette)

    def tap_call(self):
        call = Wait(self.marionette).until(expected.element_present(*self._call_button_locator))
        Wait(self.marionette).until(expected.element_displayed(call))
        call.tap()
        from gaiatest.apps.phone.regions.keypad import Keypad
        keypad = Keypad(self.marionette)
        keypad.wait_for_phone_number_ready()
        return keypad


class Message(PageRegion):

    _text_locator = (By.CSS_SELECTOR, '.bubble p')
    _attachments_locator = (By.CSS_SELECTOR, '.bubble .attachment-container.preview')
    _message_section_locator = (By.CSS_SELECTOR, '.bubble')

    def open_report(self):
        activity = self.long_press_message()
        return activity.tap_report()

    @property
    def text(self):
        return self.root_element.find_element(*self._text_locator).text

    @property
    def has_attachments(self):
        try:
github mozilla-b2g / gaia / tests / python / gaia-ui-tests / gaiatest / apps / system / regions / fullscreen_dialog.py View on Github external
# 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 marionette_driver import expected, By, Wait

from gaiatest.apps.base import Base
from gaiatest.apps.base import PageRegion
from gaiatest.form_controls.binarycontrol import GaiaBinaryControl
from gaiatest.apps.search.regions.browser import Browser


class TrackingDialog(PageRegion):

    _tracking_notice_locator = (By.ID, 'tracking-notice')
    _tracking_protection_toggle_locator = (By.ID, 'tracking-protection-toggle')
    _tracking_notice_learn_more_locator = (By.ID, 'tracking-notice-learn-more')
    _tracking_notice_confirm_locator = (By.ID, 'tracking-notice-confirm')

    def __init__(self, marionette):
        marionette.switch_to_frame()
        root = Wait(marionette).until(
            expected.element_present(*self._tracking_notice_locator))
        Wait(marionette).until(expected.element_displayed(root))
        PageRegion.__init__(self, marionette, root)

    @property
    def is_displayed(self):
        return self.root_element.is_displayed()
github mozilla-b2g / gaia / tests / python / gaia-ui-tests / gaiatest / apps / fmradio / app.py View on Github external
Wait(self.marionette).until(
            lambda m: len(self.favorite_channels) == current + 1)

    @property
    def is_power_button_on(self):
        return self.marionette.find_element(*self._power_button_locator).get_attribute('data-enabled') == 'true'

    @property
    def frequency(self):
        return float(self.marionette.find_element(*self._frequency_display_locator).text)

    @property
    def favorite_channels(self):
        return [self.FavoriteChannel(self.marionette, channel) for channel in self.marionette.find_elements(*self._favorite_list_locator)]

    class FavoriteChannel(PageRegion):
        _remove_locator = (By.CSS_SELECTOR, 'div.fav-list-remove-button')
        _frequency_locator = (By.CSS_SELECTOR, 'div.fav-list-frequency')

        @property
        def text(self):
            return float(self.root_element.find_element(*self._frequency_locator).text)

        def remove(self):
            frequency = self.marionette.find_element(*self._frequency_locator)
            self.root_element.find_element(*self._remove_locator).tap()
            Wait(self.marionette).until(expected.element_not_displayed(frequency))
github mozilla-b2g / gaia / tests / python / gaia-ui-tests / gaiatest / apps / marketplace / regions / search_results.py View on Github external
def __init__(self, marionette):
        Base.__init__(self, marionette)
        self.wait_for_element_not_present(*self._search_results_loading_locator)

    def tap_filter(self):
        self.marionette.find_element(*self._filter_button_locator).tap()
        return FilterResults(self.marionette)

    @property
    def search_results(self):
        self.wait_for_element_displayed(*self._search_result_locator)
        search_results = self.marionette.find_elements(*self._search_result_locator)
        return [Result(self.marionette, result) for result in search_results]


class Result(PageRegion):

    _name_locator = (By.CSS_SELECTOR, '.info > h3')
    _author_locator = (By.CSS_SELECTOR, '.info .author')
    _install_button_locator = (By.CSS_SELECTOR, '.button.product.install')
    _price_locator = (By.CSS_SELECTOR, '.premium.button.product')

    @property
    def name(self):
        return self.root_element.find_element(*self._name_locator).text

    @property
    def author(self):
        return self.root_element.find_element(*self._author_locator).text

    @property
    def install_button_text(self):