<commit_before># 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 pypom import Page, Region
from regions.newsletter import NewsletterEmbedForm


class BasePage(Page):

    URL_TEMPLATE = '/{locale}'

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

    def wait_for_page_to_load(self):
        super(BasePage, self).wait_for_page_to_load()
        self.wait.until(lambda s: self.is_element_present(
            By.CSS_SELECTOR, 'html.loaded'))
        return self

    @property
    def navigation(self):
        return self.Navigation(self)

    @property
    def footer(self):
        return self.Footer(self)

    @property
    def newsletter(self):
        return NewsletterEmbedForm(self)

    class Navigation(Region):

        _root_locator = (By.ID, 'nav-main')
        _toggle_locator = (By.CLASS_NAME, 'toggle')
        _menu_locator = (By.ID, 'nav-main-menu')
        _about_locator = (By.CSS_SELECTOR, 'a[data-link-name="About"]')
        _participate_locator = (By.CSS_SELECTOR, 'a[data-link-name="Participate"]')
        _firefox_locator = (By.CSS_SELECTOR, 'a[data-link-name="Firefox"]')

        def show(self):
            assert not self.is_displayed, 'Menu is already displayed'
            self.find_element(*self._toggle_locator).click()
            self.wait.until(lambda s: self.is_displayed)
            return self

        @property
        def is_displayed(self):
            toggle = self.find_element(*self._toggle_locator)
            return (self.find_element(*self._menu_locator).is_displayed() and
                toggle.get_attribute('aria-expanded') == 'true')

        def open_about(self):
            self.find_element(*self._about_locator).click()
            from about import AboutPage
            return AboutPage(self.selenium, self.page.base_url).wait_for_page_to_load()

        def open_participate(self):
            self.find_element(*self._participate_locator).click()
            from contribute.contribute import ContributePage
            return ContributePage(self.selenium, self.page.base_url).wait_for_page_to_load()

        def open_firefox(self):
            self.find_element(*self._firefox_locator).click()
            from firefox.products import ProductsPage
            return ProductsPage(self.selenium, self.page.base_url).wait_for_page_to_load()

    class Footer(Region):

        _root_locator = (By.ID, 'colophon')
        _language_locator = (By.ID, 'page-language-select')

        @property
        def language(self):
            select = self.find_element(*self._language_locator)
            option = select.find_element(By.CSS_SELECTOR, 'option[selected]')
            return option.get_attribute('value')

        @property
        def languages(self):
            el = self.find_element(*self._language_locator)
            return [o.get_attribute('value') for o in Select(el).options]

        def select_language(self, value):
            el = self.find_element(*self._language_locator)
            Select(el).select_by_value(value)
            self.wait.until(lambda s: '/{0}/'.format(value) in s.current_url)
<commit_msg>Restore waiting for the seed URL to be loaded in functional tests<commit_after># 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 pypom import Page, Region
from regions.newsletter import NewsletterEmbedForm


class BasePage(Page):

    URL_TEMPLATE = '/{locale}'

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

    def wait_for_page_to_load(self):
        self.wait.until(lambda s: self.seed_url in s.current_url)
        el = self.find_element(By.TAG_NAME, 'html')
        self.wait.until(lambda s: 'loaded' in el.get_attribute('class'))
        return self

    @property
    def navigation(self):
        return self.Navigation(self)

    @property
    def footer(self):
        return self.Footer(self)

    @property
    def newsletter(self):
        return NewsletterEmbedForm(self)

    class Navigation(Region):

        _root_locator = (By.ID, 'nav-main')
        _toggle_locator = (By.CLASS_NAME, 'toggle')
        _menu_locator = (By.ID, 'nav-main-menu')
        _about_locator = (By.CSS_SELECTOR, 'a[data-link-name="About"]')
        _participate_locator = (By.CSS_SELECTOR, 'a[data-link-name="Participate"]')
        _firefox_locator = (By.CSS_SELECTOR, 'a[data-link-name="Firefox"]')

        def show(self):
            assert not self.is_displayed, 'Menu is already displayed'
            self.find_element(*self._toggle_locator).click()
            self.wait.until(lambda s: self.is_displayed)
            return self

        @property
        def is_displayed(self):
            toggle = self.find_element(*self._toggle_locator)
            return (self.find_element(*self._menu_locator).is_displayed() and
                toggle.get_attribute('aria-expanded') == 'true')

        def open_about(self):
            self.find_element(*self._about_locator).click()
            from about import AboutPage
            return AboutPage(self.selenium, self.page.base_url).wait_for_page_to_load()

        def open_participate(self):
            self.find_element(*self._participate_locator).click()
            from contribute.contribute import ContributePage
            return ContributePage(self.selenium, self.page.base_url).wait_for_page_to_load()

        def open_firefox(self):
            self.find_element(*self._firefox_locator).click()
            from firefox.products import ProductsPage
            return ProductsPage(self.selenium, self.page.base_url).wait_for_page_to_load()

    class Footer(Region):

        _root_locator = (By.ID, 'colophon')
        _language_locator = (By.ID, 'page-language-select')

        @property
        def language(self):
            select = self.find_element(*self._language_locator)
            option = select.find_element(By.CSS_SELECTOR, 'option[selected]')
            return option.get_attribute('value')

        @property
        def languages(self):
            el = self.find_element(*self._language_locator)
            return [o.get_attribute('value') for o in Select(el).options]

        def select_language(self, value):
            el = self.find_element(*self._language_locator)
            Select(el).select_by_value(value)
            self.wait.until(lambda s: '/{0}/'.format(value) in s.current_url)

{'fraction_non_alphanumeric': 0.10935497650576677, 'fraction_numerical': 0.0014238929232521715, 'mean_word_length': 2.8382513661202187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7206911', 'n_tokens_mistral': 2166, 'n_tokens_neox': 2077, 'n_words': 433}