How to use the pypom.Page 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 / PyPOM / tests / test_page.py View on Github external
def test_seed_url_absolute(base_url, driver):
    url_template = "https://www.test.com/"

    class MyPage(Page):
        URL_TEMPLATE = url_template

    page = MyPage(driver, base_url)
    assert url_template == page.seed_url
github mozilla / PyPOM / tests / test_page.py View on Github external
def test_seed_url_keywords_multiple_params_special(base_url, driver):
    value = ("foo", "mozilla&co")
    page = Page(driver, base_url, key=value)
    seed_url = page.seed_url
    assert "key=foo" in seed_url
    assert "key=mozilla%26co" in seed_url
    import re

    assert re.match(
        r"{}\?key=(foo|mozilla%26co)&key=(foo|mozilla%26co)".format(base_url), seed_url
    )
github mozilla / mozillians-tests / pages / base.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 pypom import Page
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as expected
from selenium.webdriver.support.select import Select

from pages.auth0 import Auth0
from tests import restmail


class Base(Page):
    URL_TEMPLATE = '/{locale}'

    _logout_locator = (By.ID, 'nav-logout')

    _pending_approval_locator = (By.ID, 'pending-approval')
    _account_created_successfully_locator = (By.CSS_SELECTOR, 'div.alert:nth-child(2)')

    # Not logged in
    _sign_in_button_locator = (By.ID, 'nav-login')

    def __init__(self, selenium, base_url, locale='en-US', **url_kwargs):
        super(Base, self).__init__(selenium, base_url, locale=locale, **url_kwargs)

    @property
    def page_title(self):
        return self.wait.until(lambda s: self.selenium.title)
github mozilla / addons-frontend / tests / ui / pages / discopane.py View on Github external
"""Represent the Discovery Pane page."""

from pypom import Page, Region
from selenium.webdriver.common.by import By


class DiscoveryPane(Page):
    """Contain the locators and actions relating to the discovery pane."""

    _root_locator = (By.CLASS_NAME, 'App')
    _extensions_locator = (By.CLASS_NAME, 'extension')
    _discopane_error_alert_locator = (
        By.CSS_SELECTOR, '#discover-error .alert')
    _discopane_header_locator = (By.CLASS_NAME, 'DiscoPane-header')
    _discovery_list_item_locator = (By.ID, 'category-discover')
    _see_more_btn_locator = (By.CLASS_NAME, 'DiscoPane-amo-link')
    _themes_locator = (By.CLASS_NAME, 'theme')

    def _wait_for_page_to_load(self):
        """Wait for page load."""
        self.wait.until(
            lambda s: s.find_element(
                *self._discovery_list_item_locator).is_displayed())
github mozilla / treeherder / tests / jenkins / pages / treeherder.py View on Github external
import itertools

from pypom import Page, Region
from selenium.webdriver.common.by import By


class TreeherderPage(Page):

    _get_next_10_locator = (By.CSS_SELECTOR, 'div.btn:nth-child(1)')
    _get_next_20_locator = (By.CSS_SELECTOR, 'div.btn:nth-child(2)')
    _get_next_50_locator = (By.CSS_SELECTOR, 'div.btn:nth-child(3)')
    _pushes_locator = (By.CSS_SELECTOR, '.push:not(.row)')

    def __init__(self, driver, base_url=None, timeout=20, **url_kwargs):
        super(TreeherderPage, self).__init__(driver, base_url, timeout, **url_kwargs)

    def wait_for_page_to_load(self):
        self.wait.until(lambda s: len(self.all_jobs) >= 1)
        return self

    @property
    def all_jobs(self):
        return list(itertools.chain.from_iterable(
github mozilla / addons-server / tests / ui / pages / desktop / search.py View on Github external
from pypom import Page, Region
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as expected


class Search(Page):

    _search_box_locator = (By.CLASS_NAME, 'AutoSearchInput-query')
    _submit_button_locator = (By.CLASS_NAME, 'AutoSearchInput-submit-button')
    _search_filters_sort_locator = (By.ID, 'SearchFilters-Sort')
    _search_filters_type_locator = (By.ID, 'SearchFilters-AddonType')
    _search_filters_os_locator = (By.ID, 'SearchFilters-OperatingSystem')

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

    @property
    def result_list(self):
        return self.SearchResultList(self)
github mozilla / addons-server / tests / ui / pages / desktop / base.py View on Github external
from pypom import Page, Region
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys


class Base(Page):

    _url = '{base_url}/{locale}'
    _amo_header = (By.CLASS_NAME, 'Header')

    def __init__(self, selenium, base_url, locale='en-US', **kwargs):
        super(Base, self).__init__(
            selenium, base_url, locale=locale, timeout=30, **kwargs)

    def wait_for_page_to_load(self):
        self.wait.until(
            lambda _: self.find_element(*self._amo_header).is_displayed())
        return self

    @property
    def header(self):
        return Header(self)
github mozilla / PyPOM / tests / test_page.py View on Github external
def test_seed_url_keywords_params_space(base_url, driver):
    value = "a value"
    page = Page(driver, base_url, key=value)
    assert "{}?key={}".format(base_url, "a+value") == page.seed_url
github mozilla / experimenter / tests / integration / pages / base.py View on Github external
"""Base page."""

from pypom import Page, Region
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC


class Base(Page):

    _save_btn_locator = (By.CSS_SELECTOR, "#save-btn")

    def __init__(self, selenium, base_url, locale="en-US", **kwargs):
        super(Base, self).__init__(
            selenium, base_url, locale=locale, timeout=30, **kwargs
        )

    def wait_for_page_to_load(self):
        self.wait.until(
            EC.presence_of_element_located(self._page_wait_locator)
        )

        return self

    @property
github mozilla / mozwebqa-examples / pages / base.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 selenium.webdriver.common.by import By

from pypom import Page


class Base(Page):

    _login_locator = (By.ID, 'login')
    _logout_locator = (By.ID, 'logout')
    _notification_locator = (By.CLASS_NAME, 'flash')

    def click_login(self):
        self.find_element(*self._login_locator).click()
        from pages.login import LoginPage
        return LoginPage(self.selenium, self.base_url)

    def click_logout(self):
        self.find_element(*self._logout_locator).click()

    def login(self, username, password):
        login_page = self.click_login()
        return login_page.login(username, password)

PyPOM

python page object model for selenium

MPL-2.0
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis