Exemplo n.º 1
0
                def search_for(self, topic: str) \
                        -> List[Profile.Console.PopupConsole.Users.Result]:
                    r"""Use the pop up console to search for a given string.

                    :param str topic: the search string
                    :return: the list of users matching the search string
                    :rtype: list(:py:class:`~pages.accounts.profile. \
                                            Profile.Console.PopupConsole. \
                                            Users.Result`)

                    """
                    results_list = self.find_element(
                        *self._results_list_root_locator)
                    self.find_element(*self._search_bar_locator) \
                        .send_keys(topic)
                    search_button = self.find_element(
                        *self._search_button_locator)
                    Utility.click_option(self.driver, element=search_button)
                    try:
                        self.wait.until(
                            lambda _: Utility.has_children(results_list))
                    except TimeoutException:
                        raise AccountsException('search not completed')
                    return [
                        self.Result(self, line) for line in self.find_elements(
                            *self._search_result_row_locator)
                    ]
Exemplo n.º 2
0
    def loaded(self):
        """Wait for the page loader and table data.

        If there isn't data (eg a new book), sleep 3 seconds then return.
        """
        return (super().loaded and
                (Utility.has_children(self.find_element(*self._table_locator))
                 or (sleep(3) or True)))
Exemplo n.º 3
0
 def loaded(self):
     """Override the loaded property."""
     try:
         main = self.find_element(*self._main_locator)
         images = self.find_elements(*self._image_locator)
         return (Utility.has_children(main)
                 and Utility.is_image_visible(self.driver, image=images))
     except WebDriverException:
         return False
Exemplo n.º 4
0
        def is_displayed(self):
            """Return True if the tile has children.

            :return: ``True`` if the tile is displayed and the tile has loaded
                child elements (it entered the viewable window for at least 0.1
                seconds)
            :rtype: bool

            """
            return (self.root.is_displayed()
                    and Utility.has_children(self.root))
Exemplo n.º 5
0
    def clear_training_wheels(self) -> None:
        """Clear any joyride modals.

        :return: None

        """
        try:
            while Utility.has_children(
                    self.find_element(*self._joyride_root_selector)):
                tooltip = Tooltip(
                    self, self.find_element(*self._joyride_root_selector))
                tooltip.next()
                sleep(1)
        except NoSuchElementException:
            sleep(0.5)
Exemplo n.º 6
0
    def is_displayed(self) -> bool:
        """Return True if the pop up box is displayed.

        :return: ``True`` if the pop up box exists, has content and is not
            hidden
        :rtype: bool

        """
        exists = bool(self.root)
        if not exists:
            return False
        has_content = Utility.has_children(self.root)
        is_not_hidden = self.driver.execute_script(
            'return arguments[0].hidden != true'
            ' && arguments[0].style.display != "none";', self.root)
        return has_content and is_not_hidden
Exemplo n.º 7
0
        def panel(self):
            """Return the correct subclass panel.

            :return: the subpanel according to the course settings
            :rtype: :py:class:`~CourseSettings.StudentAccess.DirectAccess` or
                :py:class:`~CourseSettings.StudentAccess.DirectLinksOnly` or
                :py:class:`~CourseSettings.StudentAccess.Enrolled` or
                :py:class:`~CourseSettings.StudentAccess.LMS`

            """
            try:
                self.find_element(*self._lms_disabled_locator)
                return self.DirectLinksOnly(self, self.root)
            except NoSuchElementException:
                try:
                    self.find_element(*self._lms_enabled_with_enrolled_locator)
                    return self.Enrolled(self, self.root)
                except NoSuchElementException:
                    enabled = self.find_elements(
                        *self._lms_enabled_without_enrolled_locator)
                    if Utility.has_children(enabled[1]):
                        return self.LMS(self, self.root)
                    else:
                        return self.DirectAccess(self, self.root)
Exemplo n.º 8
0
 def survey_available(self):
     """Return True if a survey is available."""
     return Utility.has_children(self.find_element(*self._survey_locator))
Exemplo n.º 9
0
 def loaded(self):
     """Return True when the content is available."""
     return sleep(1) or Utility.has_children(self.content)