Esempio n. 1
0
def api_test():
    logger.error("Move mouse to 100, 100")
    hover(Location(100, 100))

    logger.error("Move mouse to 400, 100")
    hover(Location(400, 100))

    logger.error("Move mouse to 400, 400")
    hover(Location(400, 400))

    logger.error("Move mouse to 100, 400")
    hover(Location(100, 400))

    logger.error("Move mouse to 100, 100")
    hover(Location(100, 100))
Esempio n. 2
0
    def hover(self, lps=None, align=None):
        """Mouse hover.

        :param lps: Location or Pattern or String.
        :param align: Hover location alignment could be top_left, center, top_right, bottom_left, bottom_right.
        """
        return hover(lps, self._area, align)
Esempio n. 3
0
def close_window_control(window_type):
    """Click on close window control.

    :param window_type: Type of window that need to be closed.
    :return: None.
    """
    find_window_controls(window_type)

    if window_type == "auxiliary":
        if OSHelper.is_mac():
            hover(AuxiliaryWindow.RED_BUTTON_PATTERN)
            click(AuxiliaryWindow.HOVERED_RED_BUTTON)
        else:
            click(AuxiliaryWindow.CLOSE_BUTTON)
    else:
        if OSHelper.is_mac():
            hover(MainWindow.UNHOVERED_MAIN_RED_CONTROL)
            click(MainWindow.HOVERED_MAIN_RED_CONTROL)
        else:
            click(MainWindow.CLOSE_BUTTON)
Esempio n. 4
0
def cancel_in_progress_downloads_from_the_library(private_window=False):
    # Open the 'Show Downloads' window and cancel all 'in progress' downloads.
    global cancel_downloads
    if private_window:
        steps = show_all_downloads_from_library_menu_private_window()
        logger.debug('Creating a region for Private Library window.')
        try:
            find_back_button = find(NavBar.BACK_BUTTON)
        except FindError:
            raise FindError('Could not get the coordinates of the nav bar back button.')

        try:
            find_hamburger_menu = find(NavBar.HAMBURGER_MENU)
        except FindError:
            raise FindError('Could not get the coordinates of the hamburger menu.')

        region = Region(find_back_button.x - 10, find_back_button.y,
                        Screen.SCREEN_WIDTH, Screen.SCREEN_HEIGHT)
    else:
        steps = open_show_all_downloads_window_from_library_menu()
        logger.debug('Creating a region for Non-private Library window.')
        expected = exists(Library.TITLE, 10)
        assert expected is True, 'Library successfully opened.'

        try:
            find_library = find(Library.TITLE)
        except FindError:
            raise FindError('Could not get the x-coordinate of the library window title.')

        try:
            find_clear_downloads = find(Library.CLEAR_DOWNLOADS)
        except FindError:
            raise FindError('Could not get the x-coordinate of the clear_downloads button.')

        clear_downloads_width, clear_downloads_height = Library.CLEAR_DOWNLOADS.get_size()
        region = Region(find_library.x - 10, find_library.y,
                        (find_clear_downloads.x + clear_downloads_width + 20) - find_library.x, 500)

    # Cancel all 'in progress' downloads.
    expected = region.exists(DownloadManager.DownloadsPanel.DOWNLOAD_CANCEL, 5)
    expected_highlighted = region.exists(DownloadManager.DownloadsPanel.DOWNLOAD_CANCEL_HIGHLIGHTED)
    if expected or expected_highlighted:
        steps.append(Step(expected, 'The Cancel Download button is displayed properly.'))
        cancel_downloads = True
        expected_cancel = True
    else:
        steps.append(Step(True, 'There are no downloads to be cancelled.'))
        cancel_downloads = False

    cancel_pattern = DownloadManager.DownloadsPanel.DOWNLOAD_CANCEL if expected \
        else DownloadManager.DownloadsPanel.DOWNLOAD_CANCEL_HIGHLIGHTED

    if cancel_downloads:
        while expected_cancel:
            expected_cancel = region.exists(cancel_pattern, 10)
            if expected_cancel:
                click(cancel_pattern)
                if not private_window:
                    hover(Library.TITLE)
        steps.append(Step(True, 'All downloads were cancelled.'))

    if private_window:
        close_tab()
    else:
        click_window_control('close')

    return steps