Esempio n. 1
0
    def add(self) -> Page:
        """Add a new log in method to the account.

        :return: the password setup page, the Facebook log in page or the
            Google log in page
        :rtype: :py:class:`~pages.accounts.reset.SetPassword`,
            :py:class:`~pages.facebook.home.Facebook`, or
            :py:class:`~pages.google.home.Google`

        """
        provider = self.name.lower()
        base_url = None
        if 'password' in provider:
            from pages.accounts.reset import SetPassword
            Destination = SetPassword
            base_url = Utility.parent_page(self).base_url
        elif 'facebook' in provider:
            from pages.facebook.home import Facebook
            Destination = Facebook
        else:
            from pages.google.home import Google
            Destination = Google
        button = self.find_element(*self._add_button_locator)
        Utility.click_option(self.driver, element=button)
        return go_to_(Destination(self.driver, base_url=base_url))
Esempio n. 2
0
    def cancel(self) -> Profile:
        """Click the cancel x button.

        :return: the user profile
        :rtype: :py:class:`~pages.accounts.profile.Profile`

        """
        button = self.find_element(*self._cancel_button_locator)
        Utility.click_option(self.driver, element=button)
        return Utility.parent_page(self)
Esempio n. 3
0
 def select(self):
     """Click the information bucket."""
     from pages.web.impact import Impact
     from pages.web.partners import Partners
     button = self.find_element(*self._button_locator)
     base_url = Utility.parent_page(self).base_url
     destination = Impact if 'impact' in button.text.lower() \
         else Partners
     Utility.click_option(self.driver, element=button)
     return go_to_(destination(self.driver, base_url=base_url))
Esempio n. 4
0
    def accept(self) -> Profile:
        """Click the accept checkmark button.

        :return: the user profile
        :rtype: :py:class:`~pages.accounts.profile.Profile`

        """
        button = self.find_element(*self._accept_button_locator)
        Utility.click_option(self.driver, element=button)
        sleep(1.0)
        return Utility.parent_page(self)
Esempio n. 5
0
    def edit(self) -> ChangePassword:
        """Edit the password log in method.

        :return: the change password form
        :rtype: :py:class:`~pages.accounts.reset.ChangePassword`

        """
        base_url = Utility.parent_page(self).base_url
        button = self.find_element(*self._edit_button_locator)
        Utility.click_option(self.driver, element=button)
        return go_to_(ChangePassword(self.driver, base_url=base_url))
Esempio n. 6
0
    def ok(self) -> Page:
        """Click the 'OK' button.

        :return: the current page
        :rtype: :py:class:`~pypom.Page`

        """
        button = self.find_element(*self._ok_button_locator)
        Utility.click_option(self.driver, element=button)
        sleep(0.5)
        return Utility.parent_page(self)
Esempio n. 7
0
                    def sign_in_as(self) -> Profile:
                        """Sign in to Accounts as the user.

                        :return: the selected user's profile
                        :rtype: :py:class:`~pages.accounts.profile.Profile`

                        """
                        sign_in = self.find_element(*self._sign_in_locator)
                        base_url = Utility.parent_page(self).base_url
                        Utility.click_option(self.driver, element=sign_in)
                        self.driver.get(f'{base_url}{Profile.URL_TEMPLATE}')
                        return go_to_(Profile(self.driver, base_url=base_url))
Esempio n. 8
0
                def view(self) -> Page:
                    """View the reference book at the highlight's location.

                    :return: the reference book view scrolled to the location
                        of the highlight
                    :rtype: :py:class:`~pages.tutor.reference.ReferenceBook`

                    """
                    url = Utility.parent_page(self).base_url
                    from pages.tutor.reference import ReferenceBook
                    button = self.find_element(
                        *self._view_highlight_in_book_button_locator)
                    Utility.switch_to(self.driver, element=button)
                    return go_to_(ReferenceBook(self, base_url=url))
Esempio n. 9
0
                    def edit(self) -> Details:
                        """Edit the selected user.

                        :return: the user details page for the selected user
                        :rtype: :py:class:`~pages.accounts.admin.users.Details`

                        """
                        link = self.find_element(*self._edit_locator)
                        base_url = Utility.parent_page(self).base_url
                        user_id = self.id
                        Utility.switch_to(self.driver, element=link)
                        return go_to_(
                            Details(self.driver,
                                    base_url=base_url,
                                    user_id=user_id))
Esempio n. 10
0
                def _link_loader(self, locator: Selector, destination: Page) \
                        -> Page:
                    """Click a link and return the destination page.

                    :param locator: a By-styled element selector
                    :param destination: the link destination page
                    :type locator: tuple(str, str)
                    :type destination: :py:class:`~pypom.Page`
                    :return: the destination page
                    :rtype: :py:class:`~pypom.Page`

                    """
                    link = self.find_element(*locator)
                    base_url = Utility.parent_page(self).base_url
                    Utility.click_option(self.driver, element=link)
                    return go_to_(destination(self.driver, base_url=base_url))
Esempio n. 11
0
                    def view_security_log(self) -> Security:
                        r"""Return the security log for the user.

                        :return: the security log for the user
                        :rtype: :py:class:`~pages.accounts.admin.security. \
                                            Security`

                        """
                        link = self.find_element(*self._username_locator)
                        base_url = Utility.parent_page(self).base_url
                        query = link.get_attribute('href') \
                                    .split('/security_log')[-1]
                        Utility.click_option(self.driver, element=link)
                        return go_to_(
                            Security(self.driver,
                                     base_url=base_url,
                                     query_string=query))