How to use the pypom.Region function in PyPOM

To help you get started, we’ve selected a few PyPOM 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 / treeherder / tests / selenium / pages / treeherder.py View on Github external
_expand_locator = (By.CSS_SELECTOR, '.group-btn')

            def expand(self):
                assert not self.expanded
                self.find_element(*self._expand_locator).click()
                self.wait.until(lambda _: self.expanded)

            @property
            def expanded(self):
                return not self.is_element_present(*self._expand_locator)

            @property
            def jobs(self):
                return [Treeherder.ResultSet.Job(self.page, root=el) for el in self.find_elements(*self._jobs_locator)]

    class Commit(Region):

        _revision_locator = (By.CSS_SELECTOR, '.revision-holder a')
        _author_locator = (By.CSS_SELECTOR, '.user-push-initials')
        _comment_locator = (By.CSS_SELECTOR, '.revision-comment')

        @property
        def revision(self):
            return self.find_element(*self._revision_locator).text

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

        @property
        def comment(self):
            return self.find_element(*self._comment_locator).text
github mozilla / PyPOM / tests / splinter_specific / test_region.py View on Github external
def test_is_element_present_not_preset_splinter(
        self, page, splinter, splinter_strategy
    ):
        root_element = MagicMock()
        from splinter.element_list import ElementList

        root_element.configure_mock(
            **{"find_by_{0}.return_value".format(splinter_strategy): ElementList([])}
        )
        locator = (splinter_strategy, str(random.random()))
        assert not Region(page, root=root_element).is_element_present(*locator)
github mozilla / PyPOM / tests / test_region.py View on Github external
def test_root(self, page, driver):
        element = Mock()
        assert Region(page, root=element).root == element
github mozilla-lockwise / lockbox-extension / test / integration / pages / home.py View on Github external
def sign_in_button_is_displayed(self):
        """Check if sign in button is displayed."""
        try:
            self.find_elements(*self._sign_in_locator)[-1]
        except Exception:
            return False
        return True

    @property
    def entries(self):
        """List of current entries."""
        els = self.find_elements(*self._entries_locator)
        return [Entry(self, el) for el in els]


class Entry(Region):
    """Entry specific locators and functions."""

    _name_locator = (By.CSS_SELECTOR, 'div.{}'.format(
                     munged_class_name('title')))

    @property
    def name(self):
        """Return the name of the entry."""
        return self.find_element(*self._name_locator).text

    def click(self):
        """Click on the entry."""
        self.root.click()
        return self.EntryDetail(self)

    class EntryDetail(Region):
github mozilla / addons-server / tests / ui / pages / desktop / base.py View on Github external
class SearchSuggestionItem(Region):

            _item_name = (By.CLASS_NAME, 'SearchSuggestion-name')

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

            @property
            def select(self):
                self.root.click()
                from pages.desktop.details import Detail
                return Detail(self.selenium, self.page).wait_for_page_to_load()


class Footer(Region):

    _root_locator = (By.CSS_SELECTOR, '.Footer-wrapper')
    _footer_amo_links = (By.CSS_SELECTOR, '.Footer-amo-links')
    _footer_firefox_links = (By.CSS_SELECTOR, '.Footer-firefox-links')
    _footer_links = (By.CSS_SELECTOR, '.Footer-links li a')

    @property
    def addon_links(self):
        header = self.find_element(*self._footer_amo_links)
        return header.find_elements(*self._footer_links)

    @property
    def firefox_links(self):
        header = self.find_element(*self._footer_firefox_links)
        return header.find_elements(*self._footer_links)
github mozilla / treeherder / tests / selenium / pages / base.py View on Github external
def active_app(self):
            # Initially try to compare with the text of the menu item.
            # But if there's an image instead of just text, then compare the
            # ``alt`` property of the image instead.
            self.wait.until(lambda _: self.is_element_displayed(
                *self._app_menu_locator))
            menu = self.find_element(*self._app_menu_locator).text
            return menu if menu else self.find_element(
                *self._app_logo_locator).get_attribute("alt")

        def switch_app(self):
            self.find_element(*self._app_menu_locator).click()
            self.find_element(*self._switch_app_locator).click()


class Modal(Region):

    _root_locator = (By.CSS_SELECTOR, '.modal-dialog')

    @property
    def is_displayed(self):
        return self.root.is_displayed()
github mozilla-services / socorro / e2e-tests / pages / home_page.py View on Github external
class CrashStatsHomePage(CrashStatsBasePage):

    URL_TEMPLATE = '/'

    _release_channels_locator = (By.CSS_SELECTOR, '.release_channel')

    def wait_for_page_to_load(self):
        super(CrashStatsHomePage, self).wait_for_page_to_load()
        return self

    @property
    def release_channels(self):
        elements = self.find_elements(*self._release_channels_locator)
        return [self.ReleaseChannels(self, el) for el in elements]

    class ReleaseChannels(Region):

        _release_channel_header_locator = (By.TAG_NAME, 'h4')
        _top_crashers_link_locator = (By.LINK_TEXT, 'Top Crashers')

        @property
        def product_version_label(self):
            return self.find_element(*self._release_channel_header_locator).text

        def click_top_crasher(self):
            self.find_element(*self._top_crashers_link_locator).click()
            from pages.crash_stats_top_crashers_page import CrashStatsTopCrashers
            return CrashStatsTopCrashers(self.selenium, self.page.base_url)
github mozilla / treeherder / tests / selenium / pages / treeherder.py View on Github external
self.page._keyboard_shortcut(Keys.ESCAPE)
            else:
                self.find_element(*self._close_locator).click()
            self.wait.until(lambda _: not self.is_open)

        @property
        def is_open(self):
            return self.root.is_displayed() and \
                not self.find_elements(*self._loading_locator) and \
                self.job_details.result

        @property
        def job_details(self):
            return self.SummaryPanel(self.page)

        class SummaryPanel(Region):

            _root_locator = (By.ID, 'summary-panel')
            _keywords_locator = (By.CSS_SELECTOR, 'a[title="Filter jobs containing these keywords"]')
            _log_viewer_locator = (By.CLASS_NAME, 'logviewer-btn')
            _pin_job_locator = (By.ID, 'pin-job-btn')
            _result_locator = (By.CSS_SELECTOR, '#result-status-pane div:nth-of-type(1) span')

            @property
            def keywords(self):
                return self.find_element(*self._keywords_locator).text

            @property
            def result(self):
                return self.find_element(*self._result_locator).text

            def filter_by_keywords(self):
github mdn / kuma / tests / pages / dashboard.py View on Github external
self.wait.until(lambda s: int(self.find_element(*self._revision_page_input).get_attribute('value')) == 1)
        # opacity maniulation finishes
        self.wait.until(lambda s: 'opacity' not in self.find_element(*self._parent_locator).get_attribute('style'))

    @property
    def scroll_width(self):
        script = "return document.documentElement.scrollWidth;"
        return int(self.selenium.execute_script(script))

    @property
    def client_width(self):
        script = "return document.documentElement.clientWidth;"
        return int(self.selenium.execute_script(script))


class DashboardRow(Region):

    _root_locator = (By.CSS_SELECTOR, '.dashboard-row')
    _ban_ip_locator = (By.CSS_SELECTOR, '.dashboard-ban-ip-link')
    _spam_ham_button_locator = (By.CSS_SELECTOR, '.spam-ham-button')

    @property
    def revision_id(self):
        return self.root.get_attribute('data-revision-id')

    @property
    def is_ip_ban_present(self):
        try:
            self.find_element(*self._ban_ip_locator)
        except NoSuchElementException:
            return False
        return True
github mozilla / addons-server / tests / ui / regions / desktop / search.py View on Github external
class Search(Region):

    _search_results_locator = (By.CLASS_NAME, 'SearchForm-suggestions-item')

    def wait_for_region_to_load(self):
        self.wait.until(
            expected.invisibility_of_element_located((By.CLASS_NAME, 'LoadingText'))
        )
        return self

    @property
    def result_list(self):
        items = self.find_elements(*self._search_results_locator)
        return [self.SearchResultList(self.page, el) for el in items]

    class SearchResultList(Region):

        _search_item_name_locator = (By.CLASS_NAME, 'Suggestion-name')
        _search_item_link_locator = (By.CLASS_NAME, 'Suggestion')

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

        def link(self):
            self.find_element(*self._search_item_link_locator).click()
            from pages.desktop.detail import Detail

            return Detail(self.selenium, self.page.base_url).wait_for_page_to_load()

PyPOM

python page object model for selenium

MPL-2.0
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis