def run(self, firefox):
        file_to_download = DownloadFiles.EXTRA_SMALL_FILE_5MB

        navigate(LocalWeb.THINKBROADBAND_TEST_SITE)

        download_file(file_to_download, DownloadFiles.OK)

        expected = exists(NavBar.DOWNLOADS_BUTTON_BLUE, 10)
        assert expected is True, 'Downloads button found.'

        expected = exists(DownloadManager.DownloadState.COMPLETED, 10)
        assert expected is True, 'Completed information is displayed.'

        right_click(DownloadManager.DownloadState.COMPLETED)
        click(DownloadManager.DownloadsContextMenu.CLEAR_PREVIEW_PANEL)

        # Enable the download button in the nav bar.
        auto_hide_download_button()
        time.sleep(Settings.DEFAULT_UI_DELAY_LONG)
        # Check that all of the downloads were cleared.
        expected = exists(DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON, 10)
        assert expected is True, 'Downloads button has been found.'
        click(DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON)
        expected = exists(
            DownloadManager.DownloadsPanel.NO_DOWNLOADS_FOR_THIS_SESSION, 10)
        assert expected is True, 'All downloads were cleared.'
    def run(self, firefox):
        # Enable the download button in the nav bar.
        auto_hide_download_button()

        expected = exists(NavBar.DOWNLOADS_BUTTON, 10)
        assert (expected is True
                ), "Downloads button successfully activated in the nav bar."

        navigate(LocalWeb.THINKBROADBAND_TEST_SITE)

        # Wait for the page to be loaded.
        try:
            wait(DownloadFiles.VERY_LARGE_FILE_1GB, 10)
            logger.debug("File is present in the page.")
        except FindError:
            raise FindError("File is not present in the page.")

        select_throttling(NetworkOption.GPRS)

        max_attempts = 10
        while max_attempts > 0:
            if exists(DownloadFiles.VERY_LARGE_FILE_1GB, 2):
                # Wait a moment to ensure button can be grabbed for drag operation
                expected = exists(DownloadFiles.VERY_LARGE_FILE_1GB, 10)
                assert (
                    expected is True
                ), "Downloads button successfully activated in the nav bar."
                drag_drop(
                    DownloadFiles.VERY_LARGE_FILE_1GB,
                    NavBar.DOWNLOADS_BUTTON,
                    duration=2,
                )
                max_attempts = 0
            max_attempts -= 1

        expected = exists(DownloadFiles.DOWNLOAD_FILE_NAME_1GB, 10)
        assert (
            expected is True
        ), "The downloaded file name is properly displayed in the Downloads panel."

        # Cancel the download.
        expected = exists(DownloadManager.DownloadsPanel.DOWNLOAD_CANCEL, 10)
        assert expected is True, "The 'X' button is found in the Downloads panel."

        click(DownloadManager.DownloadsPanel.DOWNLOAD_CANCEL)
    def run(self, firefox):
        download_files_list = [
            DownloadFiles.MEDIUM_FILE_100MB, DownloadFiles.MEDIUM_FILE_50MB,
            DownloadFiles.SMALL_FILE_20MB, DownloadFiles.SMALL_FILE_10MB,
            DownloadFiles.EXTRA_SMALL_FILE_5MB
        ]
        downloads_library_list = [
            DownloadFiles.LIBRARY_DOWNLOADS_5MB,
            DownloadFiles.LIBRARY_DOWNLOADS_10MB,
            DownloadFiles.LIBRARY_DOWNLOADS_20MB,
            DownloadFiles.LIBRARY_DOWNLOADS_50MB,
            DownloadFiles.LIBRARY_DOWNLOADS_100MB
        ]

        new_private_window()
        expected = exists(PrivateWindow.private_window_pattern, 10)
        assert expected is True, 'Private window successfully loaded.'

        open_downloads()

        expected = exists(DownloadManager.AboutDownloads.NO_DOWNLOADS, 10)
        assert expected is True, 'The downloads category is brought to view and the following message is displayed '
        'in the tab: \'There are no downloads\'.'

        # Perform 5 downloads of your choice and go to the Downloads category from the Library.
        new_tab()
        navigate(LocalWeb.THINKBROADBAND_TEST_SITE)

        for pattern in download_files_list:
            download_file(pattern, DownloadFiles.OK)
            file_index = download_files_list.index(pattern)

            if file_index == 0:
                expected = exists(NavBar.DOWNLOADS_BUTTON, 10)
        assert expected is True, 'Download button found in the page.'

        click(
            DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON.target_offset(
                -50, 0))

        open_library()
        expected = exists(Library.TITLE, 10)
        assert expected is True, 'Library successfully opened.'

        click(Library.DOWNLOADS)

        # Check that all the downloads are successful and displayed in the Downloads category.
        for pattern in downloads_library_list:
            expected = exists(pattern, 50)
            assert expected is True, '%s file found in the Library, Downloads section.' \
                                     % str(pattern.get_filename()).replace('_library_downloads.png', '')

        click_window_control('close')
        close_window()

        # In the non-private window, open the Downloads Panel and the Downloads category from the Library.
        open_library()
        expected = exists(Library.TITLE, 10)
        assert expected is True, 'Library successfully opened.'

        click(Library.DOWNLOADS)

        # Check that downloads from the private window are not displayed in non private window.
        for pattern in downloads_library_list:
            expected = exists(pattern, 2)
            assert expected is False, '%s file not found in the Library, Downloads section.' \
                                      % str(pattern.get_filename()).replace('_library_downloads.png', '')

        click_window_control('close')

        auto_hide_download_button()

        expected = exists(DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON, 10)
        assert expected is True, 'Downloads button found in the non private window.'

        time.sleep(Settings.DEFAULT_UI_DELAY_LONG)

        click(DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON)
        expected = exists(
            DownloadManager.DownloadsPanel.NO_DOWNLOADS_FOR_THIS_SESSION, 10)
        assert expected is True, 'There are no downloads displayed in the Downloads Panel.'