def run(self, firefox): file_to_download = DownloadFiles.VERY_LARGE_FILE_1GB navigate(LocalWeb.THINKBROADBAND_TEST_SITE) download_file(file_to_download, DownloadFiles.OK) expected = exists(DownloadManager.DownloadState.PROGRESS, 10) assert expected is True, 'Progress information is displayed.' right_click(DownloadManager.DownloadState.PROGRESS) click(DownloadManager.DownloadsContextMenu.PAUSE) expected = exists(DownloadManager.DownloadState.PAUSED, 10) assert expected is True, 'Download was paused.' right_click(DownloadManager.DownloadState.PAUSED) click(DownloadManager.DownloadsContextMenu.RESUME) expected = exists(DownloadManager.DownloadState.PROGRESS, 10) assert expected is True, 'Download was resumed.' # Cancel 'in progress' download. click(DownloadManager.DownloadsPanel.DOWNLOAD_CANCEL) # Refocus the firefox window. exists(LocationBar.STAR_BUTTON_UNSTARRED, 10) click(LocationBar.STAR_BUTTON_UNSTARRED.target_offset(+30, 0))
def run(self, firefox): 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.GOOD_3G) download_file(DownloadFiles.VERY_LARGE_FILE_1GB, DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, '\'Downloads\' button found.' # Check download summary. expected = exists(DownloadFiles.DOWNLOAD_FILE_NAME_1GB, 10) assert expected is True, 'The 1GB download in progress is properly displayed.' expected = exists(DownloadManager.DownloadsPanel.TIME_LEFT.similar(0.7), 10) assert expected is True, 'Time left information is displayed.' expected = exists(DownloadManager.DownloadsPanel.BYTES_SECOND, 10) assert expected is True, 'Speed of download is displayed.' # 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): new_private_window() expected = exists(PrivateWindow.private_window_pattern, 10) assert expected is True, "Private window successfully loaded." type(text="o") download_files_list = [ DownloadFiles.VERY_LARGE_FILE_1GB, DownloadFiles.EXTRA_LARGE_FILE_512MB, ] navigate(LocalWeb.DOWNLOAD_TEST_SITE) # Wait for the page to be loaded. try: wait(DownloadFiles.VERY_LARGE_FILE_1GB, 30) logger.debug("File is present in the page.") except FindError: raise FindError("File is not present in the page.") select_throttling(NetworkOption.GOOD_3G) expected = exists(NavBar.RELOAD_BUTTON, 10) assert expected is True, "Reload button found in the page." click(NavBar.RELOAD_BUTTON) expected = exists(DownloadFiles.STATUS_200, 10) assert expected is True, "Page successfully reloaded." 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(NavBar.DOWNLOADS_BUTTON.target_offset(-50, 0)) click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadManager.DownloadState.SPEED_PER_SECOND, 10) assert expected is True, "At least one download is in progress." click(NavBar.DOWNLOADS_BUTTON.target_offset(-50, 0)) close_window() expected = exists(DownloadFiles.CANCEL_ALL_DOWNLOADS_POP_UP, 10) assert expected is True, "'Cancel all downloads?' warning pop-up is displayed." # Cancel all downloads. type(Key.ENTER) time.sleep(Settings.DEFAULT_UI_DELAY_LONG) # Refocus the firefox window. expected = exists(LocationBar.STAR_BUTTON_UNSTARRED, 10) assert expected is True, "'Star button' is displayed." exists(LocationBar.STAR_BUTTON_UNSTARRED, 10) click(LocationBar.STAR_BUTTON_UNSTARRED.target_offset(+40, 0))
def run(self, firefox): navigate(LocalWeb.THINKBROADBAND_TEST_SITE) download_file(DownloadFiles.EXTRA_SMALL_FILE_5MB, DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON_BLUE, 10) assert expected is True, "Downloads button found." expected = exists(DownloadFiles.DOWNLOADS_PANEL_5MB_COMPLETED, 10) assert expected is True, "Small size file download is completed." expected = exists( DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER, 10) assert expected is True, "Containing folder button is available." # Navigate to Downloads folder. click(DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER) expected = exists(DownloadManager.DOWNLOADS_FOLDER, 10) assert expected is True, "Downloads folder is displayed." expected = exists(DownloadFiles.FOLDER_VIEW_5MB_HIGHLIGHTED, 10) assert expected is True, "Downloaded file is found." delete_selected_file() try: expected = wait_vanish(DownloadFiles.FOLDER_VIEW_5MB_HIGHLIGHTED, 10) assert expected is True, "The file was successfully deleted." except FindError: raise FindError("The file was not deleted.") # Close download folder window. click_window_control("close") try: expected = wait_vanish(DownloadManager.DOWNLOADS_FOLDER, 10) assert expected is True, "The downloads folder was closed." except FindError: raise FindError("The downloads folder was not closed.") # Switch the focus on firefox browser. expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, "Download button found in the page." click(NavBar.DOWNLOADS_BUTTON.target_offset(-70, 15)) click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadManager.Downloads.EXTRA_SMALL_FILE_5MB_ZIP, 10) assert expected is True, "Previously downloaded file is displayed." expected = exists(DownloadManager.Downloads.FILE_MOVED_OR_MISSING, 10) assert ( expected is True ), "Previously downloaded file has status: 'File moved or missing'."
def run(self, firefox): if OSHelper.is_windows(): download_available = False else: download_available = True navigate( "https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/" ) download_file(DownloadFiles.FIREFOX_INSTALLER.similar(0.8), DownloadFiles.OK, expect_accept_download_available=download_available) expected = exists(NavBar.DOWNLOADS_BUTTON_BLUE.similar(0.8), FirefoxSettings.HEAVY_SITE_LOAD_TIMEOUT) assert expected is True, "Downloads button found." expected = exists(DownloadManager.DownloadState.COMPLETED, FirefoxSettings.HEAVY_SITE_LOAD_TIMEOUT * 2) assert expected is True, "Firefox installer download is completed." expected = exists(DownloadManager.DownloadsPanel.OPEN_DOWNLOAD_FOLDER, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "Containing folder button is available." # Navigate to Downloads folder. click(DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER) if OSHelper.is_linux(): click(Pattern("linux_folder_icon.png")) expected = exists(DownloadManager.DOWNLOADS_FOLDER, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "Downloads folder is displayed." if OSHelper.is_mac(): time.sleep(FirefoxSettings.TINY_FIREFOX_TIMEOUT) type("2", modifier=KeyModifier.CMD) expected = exists(DownloadFiles.FIREFOX_INSTALLER_HIGHLIGHTED, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "Firefox installer is displayed in downloads folder." click_window_control("close") expected = exists(NavBar.DOWNLOADS_BUTTON, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "Download button found in the page." click( DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON.target_offset( -50, 0))
def run(self, firefox): download_files_list = [DownloadFiles.SMALL_FILE_10MB, DownloadFiles.EXTRA_SMALL_FILE_5MB] downloads_library_list = [DownloadFiles.LIBRARY_DOWNLOADS_5MB, DownloadFiles.LIBRARY_DOWNLOADS_10MB] 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 the Downloads Panel and select Show All Downloads. expected = exists(NavBar.DOWNLOADS_BUTTON_BLUE, 10) assert expected is True, '\'Downloads\' button found.' mouse.move(Location(Screen.SCREEN_WIDTH / 4 + 100, Screen.SCREEN_HEIGHT / 4)) click(NavBar.DOWNLOADS_BUTTON_BLUE) expected = exists(DownloadManager.SHOW_ALL_DOWNLOADS, 10) assert expected is True, '\'Show all downloads\' button found.' click(DownloadManager.SHOW_ALL_DOWNLOADS) expected = exists(Library.DOWNLOADS, 10) assert expected is True, 'The Downloads button is displayed in the Library.' 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, 10) assert expected is True, ('%s file found in the Library, Downloads section.' % str(pattern.get_filename()).replace('_library_downloads.png', '')) right_click(DownloadFiles.LIBRARY_DOWNLOADS_5MB) type(text='d') # Check that all the downloads are removed from the Library. for pattern in downloads_library_list: try: expected = wait_vanish(pattern, 5) assert expected is True, ('%s file not found in the Library, Downloads section.' % str(pattern.get_filename()).replace('_library_downloads.png', '')) except FindError: raise FindError('Downloads are still present in the Library.') click_window_control('close') # Check that there are no downloads displayed in the 'about:downloads' page. navigate('about:downloads') expected = exists(DownloadManager.AboutDownloads.NO_DOWNLOADS, 10) assert expected is True, 'There are no downloads displayed in the \'about:downloads\' page.'
def run(self, firefox): download_files_list = [ DownloadFiles.VERY_LARGE_FILE_1GB, DownloadFiles.EXTRA_LARGE_FILE_512MB, ] navigate(LocalWeb.DOWNLOAD_TEST_SITE) # Wait for the page to be loaded. try: wait(DownloadFiles.VERY_LARGE_FILE_1GB, 30) logger.debug("File is present in the page.") except FindError: raise FindError("File is not present in the page.") select_throttling(NetworkOption.GOOD_3G) expected = exists(NavBar.RELOAD_BUTTON, 10) assert expected is True, "Reload button found in the page." click(NavBar.RELOAD_BUTTON) expected = exists(DownloadFiles.STATUS_200, 10) assert expected is True, "Page successfully reloaded." 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(NavBar.DOWNLOADS_BUTTON.target_offset(-50, 0)) click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadManager.DownloadState.SPEED_PER_SECOND, 10) assert expected is True, "At least one download is in progress." click(NavBar.DOWNLOADS_BUTTON.target_offset(-50, 0)) quit_firefox() expected = exists(DownloadFiles.CANCEL_ALL_DOWNLOADS_POP_UP, 10) assert expected is True, "'Cancel all downloads?' warming pop-up is displayed." # Dismiss warming pop-up. type(text=Key.ESC) # Cancel all 'in progress' downloads. cancel_and_clear_downloads() # Refocus the firefox window. exists(LocationBar.STAR_BUTTON_UNSTARRED, 10) click(LocationBar.STAR_BUTTON_UNSTARRED.target_offset(+30, 0))
def run(self, firefox): download_files_list = [ DownloadFiles.EXTRA_SMALL_FILE_5MB, DownloadFiles.VERY_LARGE_FILE_1GB, ] 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.GOOD_3G) 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 the Downloads Panel. click(NavBar.DOWNLOADS_BUTTON) # Check that the 5MB download is complete. expected = exists(DownloadFiles.DOWNLOADS_PANEL_5MB_COMPLETED, 90) assert expected is True, "The 5MB download is complete." # Open the context menu and select 'Clear Preview Panel'. right_click(DownloadFiles.DOWNLOADS_PANEL_5MB_COMPLETED) type(text="a") # Check that the 1GB download in progress is still displayed. expected = exists(DownloadFiles.DOWNLOAD_FILE_NAME_1GB, 10) assert expected is True, "The 1GB download in progress is properly displayed." # Stop the active download. expected = exists(DownloadManager.DownloadsPanel.DOWNLOAD_CANCEL, 10) assert expected is True, "The 'X' button is properly displayed." click(DownloadManager.DownloadsPanel.DOWNLOAD_CANCEL)
def run(self, firefox): navigate( 'https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/' ) download_file(DownloadFiles.FIREFOX_INSTALLER.similar(0.85), DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON_BLUE, 10) assert expected is True, 'Downloads button found.' expected = exists(DownloadManager.DownloadState.COMPLETED, 90) assert expected is True, 'Firefox installer download is completed.' expected = exists(DownloadManager.DownloadsPanel.OPEN_DOWNLOAD_FOLDER, 10) assert expected is True, 'Containing folder button is available.' # Navigate to Downloads folder. click(DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER) if OSHelper.is_linux(): click(Pattern('linux_folder_icon.png')) expected = exists(DownloadManager.DOWNLOADS_FOLDER, 10) assert expected is True, 'Downloads folder is displayed.' expected = exists(DownloadFiles.FIREFOX_INSTALLER_HIGHLIGHTED, 10) assert expected is True, 'Firefox installer is displayed in downloads folder.' click_window_control('close') 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))
def run(self, firefox): # Perform some downloads. download_files_list = [ DownloadFiles.SMALL_FILE_20MB, DownloadFiles.SMALL_FILE_10MB, DownloadFiles.EXTRA_SMALL_FILE_5MB, ] 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 the Downloads Panel. expected = exists(NavBar.DOWNLOADS_BUTTON_BLUE, 30) assert expected is True, "'Downloads' button found." click(NavBar.DOWNLOADS_BUTTON_BLUE) # Check that the 5MB download is complete. expected = exists(DownloadFiles.DOWNLOADS_PANEL_5MB_COMPLETED, 10) assert expected is True, "The 5MB download is complete." expected = exists(DownloadFiles.DOWNLOAD_FILE_NAME_10MB, 10) assert expected is True, "The 10MB file found in the download manager." # Drag and drop the 10MB file from download manager in to the tab bar. drag_drop(DownloadFiles.DOWNLOAD_FILE_NAME_10MB, Location(400, 30)) try: wait(DownloadFiles.OK, 5) logger.debug("The download dialog is triggered in the page.") click_window_control("close") time.sleep(Settings.DEFAULT_UI_DELAY_LONG) except FindError: raise FindError("The download dialog is not triggered in the page.") # Right click on another download and select 'Copy Download Link'. click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOAD_FILE_NAME_20MB, 10) assert expected is True, "The 20MB file found in the download manager." right_click(DownloadFiles.DOWNLOAD_FILE_NAME_20MB) click(DownloadManager.DownloadsContextMenu.COPY_DOWNLOAD_LINK) new_tab() select_location_bar() edit_paste() type(Key.ENTER) try: wait(DownloadFiles.OK, 5) logger.debug("The download dialog is triggered in the page.") click_window_control("close") time.sleep(Settings.DEFAULT_UI_DELAY) except FindError: raise FindError("The download dialog is not triggered in the page.")
def run(self, firefox): navigate(LocalWeb.THINKBROADBAND_TEST_SITE) download_files_list = [DownloadFiles.SMALL_FILE_20MB, DownloadFiles.SMALL_FILE_10MB, DownloadFiles.EXTRA_SMALL_FILE_5MB] for f in download_files_list: download_file(f, DownloadFiles.OK) file_index = download_files_list.index(f) 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)) click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER, 10) assert expected is True, 'Containing folder button is available.' click(DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER) if OSHelper.is_linux(): click(Pattern('linux_folder_icon.png')) expected = exists(DownloadManager.DOWNLOADS_FOLDER, 10) assert expected is True, 'Downloads folder is displayed.' # Delete the downloads folder force_delete_folder(PathManager.get_downloads_dir()) click_window_control('close') expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) downloads_button = find(NavBar.DOWNLOADS_BUTTON) file_20_mb = find(DownloadFiles.DOWNLOAD_FILE_NAME_20MB) region_20_mb = Region(file_20_mb.x - 10, file_20_mb.y, downloads_button.x - file_20_mb.x, 100) expected = region_20_mb.exists(DownloadManager.DownloadState.MISSING_FILE, 10) assert expected is True, '20 MB file removed.' file_10_mb = find(DownloadFiles.DOWNLOAD_FILE_NAME_10MB) region_10_mb = Region(file_10_mb.x - 10, file_10_mb.y, downloads_button.x - file_10_mb.x, file_20_mb.y - file_10_mb.y) expected = region_10_mb.exists(DownloadManager.DownloadState.MISSING_FILE, 10) assert expected is True, '10 MB file was removed.' file_5_mb = find(DownloadFiles.DOWNLOAD_FILE_NAME_5MB) region_5_mb = Region(file_5_mb.x - 10, file_5_mb.y, downloads_button.x - file_5_mb.x, file_10_mb.y - file_5_mb.y) expected = region_5_mb.exists(DownloadManager.DownloadState.MISSING_FILE, 10) assert expected is True, '5 MB file removed.' click(DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON.target_offset(-50, 0)) download_file(DownloadFiles.EXTRA_SMALL_FILE_5MB, DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOADS_PANEL_20MB_MISSING.similar(0.75), 10) assert expected is True, 'Missing 20 MB file is displayed.' expected = exists(DownloadFiles.DOWNLOADS_PANEL_10MB_MISSING.similar(0.75), 10) assert expected is True, 'Missing 10 MB file is displayed.' expected = exists(DownloadFiles.DOWNLOADS_PANEL_5MB_COMPLETED.similar(0.75), 10) assert expected is True, 'Completed 5 MB file is displayed.' expected = exists(DownloadFiles.DOWNLOADS_PANEL_5MB_MISSING.similar(0.75), 10) assert expected is True, 'Missing 5 MB file is displayed.' click(DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER) expected = exists(DownloadManager.DOWNLOADS_FOLDER, 10) assert expected is True, 'Downloads folder was recreated.' if OSHelper.is_linux(): click(Pattern('linux_folder_icon.png')) # Assert the newly created downloads folder expected = exists(DownloadManager.DOWNLOADS_FOLDER, 10) assert expected is True, 'Downloads folder was recreated.' click_window_control('close') click(DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON.target_offset(-50, 0))
def run(self, firefox): navigate(LocalWeb.DOWNLOAD_TEST_SITE) # Wait for the page to be loaded. try: wait(DownloadFiles.EXTRA_SMALL_FILE_5MB, 10) logger.debug("File is present in the page.") except FindError: raise FindError("File is not present in the page.") download_file(DownloadFiles.EXTRA_SMALL_FILE_5MB, DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON_BLUE, 10) assert expected is True, "Downloads button found." click(NavBar.HOME_BUTTON.target_offset(70, 0)) # Navigate to about:preferences. navigate("about:preferences#search") expected = exists(AboutPreferences.ABOUT_PREFERENCE_SEARCH_PAGE_PATTERN, 10) assert ( expected is True ), "The 'about:preferences#search' page successfully loaded." expected = exists(AboutPreferences.FIND_IN_OPTIONS, 10) assert expected is True, "'Find in Options' search field is displayed." click(AboutPreferences.FIND_IN_OPTIONS) paste("downloads") expected = exists(AboutPreferences.DOWNLOADS, 10) assert expected is True, "The 'Downloads' section is displayed." click(AboutPreferences.BROWSE) expected = exists(AboutPreferences.DOWNLOADS, 10) assert expected is True, "'New Folder' button is displayed." click(Utils.NEW_FOLDER) expected = exists(Utils.NEW_FOLDER_HIGHLIGHTED, 10) assert expected is True, "'New Folder' is highlighted." paste("new_downloads_folder") type(Key.ENTER) expected = exists(Utils.NEW_DOWNLOADS_FOLDER_HIGHLIGHTED, 10) assert expected is True, "'New Downloads Folder' is created." expected = exists(Utils.SELECT_FOLDER, 10) assert expected is True, "'Select Folder' option is available." click(Utils.SELECT_FOLDER) try: expected = wait_vanish(Utils.SELECT_FOLDER, 10) assert expected is True, "Downloads folder option window is dismissed." except FindError: logger.error("Downloads folder option is still displayed.") time.sleep(10) navigate(LocalWeb.DOWNLOAD_TEST_SITE) # Wait for the page to be loaded. try: wait(DownloadFiles.SMALL_FILE_10MB, 10) logger.debug("File is present in the page.") except FindError: raise FindError("File is not present in the page.") download_file(DownloadFiles.SMALL_FILE_10MB, DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON_BLUE, 10) assert expected is True, "Downloads button turns blue." click(NavBar.DOWNLOADS_BUTTON_BLUE) expected = exists(DownloadFiles.DOWNLOADS_PANEL_5MB_COMPLETED, 10) assert expected is True, "The 5MB download is complete." file_5_mb = find(DownloadFiles.DOWNLOADS_PANEL_5MB_COMPLETED) region_5_mb = Region(file_5_mb.x, file_5_mb.y - 10, 500, 50) expected = region_5_mb.exists( DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER, 10 ) assert expected is True, "Containing folder icon is available for 5mb file." region_5_mb.click(DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER) # Workaround to avoid 1513494 bug on Linux. if OSHelper.is_linux(): click(Pattern("linux_folder_icon.png")) expected = exists(DownloadManager.DOWNLOADS_FOLDER, 10) assert expected is True, "Default Downloads folder is displayed." expected = exists(DownloadFiles.FOLDER_VIEW_5MB_HIGHLIGHTED, 10) assert expected is True, "Downloaded file is found." close_tab() # Refocus the firefox window. click(NavBar.HOME_BUTTON.target_offset(70, 0)) click(NavBar.DOWNLOADS_BUTTON_BLUE) expected = exists(DownloadFiles.DOWNLOADS_PANEL_10MB_COMPLETED.similar(0.7), 10) assert expected is True, "The 10MB download is complete." file_10_mb = find(DownloadFiles.DOWNLOADS_PANEL_10MB_COMPLETED) region_10_mb = Region(file_10_mb.x, file_10_mb.y - 10, 500, 50) expected = region_10_mb.exists( DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER, 10 ) assert expected is True, "Containing folder icon is available for 10mb file." region_10_mb.click(DownloadManager.DownloadsPanel.OPEN_CONTAINING_FOLDER) # Workaround to avoid 1513494 bug on Linux. if OSHelper.is_linux(): click(Pattern("linux_folder_icon.png")) expected = exists(DownloadManager.NEW_DOWNLOADS_FOLDER, 10) assert expected is True, "New Downloads folder is displayed." expected = exists(DownloadFiles.FOLDER_VIEW_10MB_HIGHLIGHTED, 10) assert expected is True, "10mb file is displayed in the newly downloads folder." close_tab() # Refocus the firefox window. click(NavBar.HOME_BUTTON.target_offset(70, 0))
def run(self, firefox): download_files_list = [ DownloadFiles.SMALL_FILE_20MB, DownloadFiles.SMALL_FILE_10MB, DownloadFiles.EXTRA_SMALL_FILE_5MB, ] downloads_library_list = [ DownloadFiles.LIBRARY_DOWNLOADS_5MB_HIGHLIGHTED, DownloadFiles.LIBRARY_DOWNLOADS_10MB, DownloadFiles.LIBRARY_DOWNLOADS_20MB, ] 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 the Library - Downloads section. open_downloads() expected = exists(Library.TITLE, 10) assert expected is True, "Library successfully opened." # Check that all the downloads are successful and displayed in the Downloads category from the Library. for pattern in downloads_library_list: expected = exists(pattern, 10) assert expected is True, ( "%s file found in the Library, Downloads section." % str(pattern.get_filename())) click_window_control("close") # Check that all the downloads are also displayed in the 'about:downloads' page. new_tab() navigate("about:downloads") try: wait(DownloadFiles.LIBRARY_DOWNLOADS_20MB, 10) logger.debug("The page successfully loaded.") except FindError: raise FindError("The page did not load, aborting.") for pattern in downloads_library_list: if pattern == DownloadFiles.LIBRARY_DOWNLOADS_5MB_HIGHLIGHTED.similar( 0.75): # Sometimes the 5MB file is highlighted and sometimes not. Focusing it to make the test case stable. click(DownloadFiles.LIBRARY_DOWNLOADS_20MB) repeat_key_up(3) expected = exists(pattern, 10) assert expected is True, ( "%s file found in the 'about:downloads' page." % str(pattern.get_filename())) close_tab() # Cancel all 'in progress' downloads. cancel_in_progress_downloads_from_the_library()
def run(self, firefox): download_files_list = [ DownloadFiles.SMALL_FILE_10MB, DownloadFiles.EXTRA_SMALL_FILE_5MB ] downloads_library_list = [ DownloadFiles.LIBRARY_DOWNLOADS_5MB, DownloadFiles.LIBRARY_DOWNLOADS_10MB ] navigate(LocalWeb.DOWNLOAD_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, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "Download button found in the page." click( DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON.target_offset( -50, 0)) click(DownloadManager.DownloadsPanel.DOWNLOADS_BUTTON) expected = exists(DownloadManager.SHOW_ALL_DOWNLOADS, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "'Show all downloads' button found." click(DownloadManager.SHOW_ALL_DOWNLOADS) expected = exists(Library.DOWNLOADS, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "The Downloads button is displayed in the Library." 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, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "%s file found in the Library, Downloads section." % str( pattern.get_filename()).replace("_library_downloads.png", "") right_click(DownloadFiles.LIBRARY_DOWNLOADS_10MB) time.sleep(Settings.DEFAULT_MOVE_MOUSE_DELAY) type(text="d") # Check that all the downloads are removed from the Library. for pattern in downloads_library_list: try: expected = wait_vanish(pattern, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "%s file not found in the Library, Downloads section." % str( pattern.get_filename()).replace("_library_downloads.png", "") except FindError: raise FindError("Downloads are still present in the Library.") click_window_control("close") # Check that there are no downloads displayed in the 'about:downloads' page. navigate("about:downloads") expected = exists(DownloadManager.AboutDownloads.NO_DOWNLOADS, FirefoxSettings.FIREFOX_TIMEOUT) assert expected is True, "There are no downloads displayed in the 'about:downloads' page."
def run(self, firefox): # Navigate to about:preferences. navigate('about:preferences#search') expected = exists(AboutPreferences.ABOUT_PREFERENCE_SEARCH_PAGE_PATTERN, 10) assert expected is True, 'The \'about:preferences#search\' page successfully loaded.' expected = exists(AboutPreferences.FIND_IN_OPTIONS, 10) assert expected is True, '\'Find in Options\' search field is displayed.' click(AboutPreferences.FIND_IN_OPTIONS) paste('dangerous') expected = exists(AboutPreferences.DECEPTIVE_CONTENT_AND_DANGEROUS_SOFTWARE, 10) assert expected is True, 'Deceptive content and dangerous software section is displayed.' expected = exists(AboutPreferences.BLOCK_DANGEROUS_DOWNLOADS, 10) assert expected is True, '\'Block dangerous downloads\' option is available.' expected = exists(AboutPreferences.WARN_UNWANTED_UNCOMMON_SOFTWARE, 10) assert expected is True, '\'Warm you about unwanted and uncommon software\' option is available.' option_1 = find(AboutPreferences.BLOCK_DANGEROUS_AND_DECEPTIVE_CONTENT) region_option_1 = Region(option_1.x - 100, option_1.y - 10, 500, 40) if region_option_1.exists(AboutPreferences.CHECKED_BOX, 10): click(AboutPreferences.BLOCK_DANGEROUS_AND_DECEPTIVE_CONTENT) expected = region_option_1.exists(AboutPreferences.UNCHECKED_BOX, 10) assert expected is True, '\'Block dangerous and deceptive content\' option is unchecked.' # expected = exists(AboutPreferences.BLOCK_DANGEROUS_DOWNLOADS_GRAYED_OUT.exact(), 10) # assert_true(self, expected, '\'Block dangerous downloads\' option is grayed out.') # expected = exists(AboutPreferences.WARN_UNWANTED_UNCOMMON_SOFTWARE_GRAYED_OUT.exact(), 10) # assert_false(self, expected, '\'Warm you about unwanted and uncommon software\' option is not grayed out.') navigate('http://testsafebrowsing.appspot.com/') # Download all items from Desktop Download Warning. expected = exists(DownloadFiles.MALICIOUS, 10) assert expected is True, '\'"malicious" warning, based on content\' link has been found.' width, height = DownloadFiles.MALICIOUS.get_size() download_file(DownloadFiles.MALICIOUS.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(DownloadFiles.DOWNLOADS_PANEL_CONTENT_COMPLETED, 10) assert expected is True, '\'"malicious" warning, based on content\' download file is completed.' expected = exists(DownloadFiles.MALICIOUS_HTTPS, 10) assert expected is True, '\'"malicious" warning, based on content with https\' link has been found.' width, height = DownloadFiles.MALICIOUS_HTTPS.get_size() download_file(DownloadFiles.MALICIOUS_HTTPS.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOADS_PANEL_CONTENT1_COMPLETED, 10) assert expected is True, '\'"malicious" warning, based on content with https\' download file is completed.' expected = exists(DownloadFiles.DANGEROUS_HOST_WARNING, 10) assert expected is True, '\'"dangerous host" warning\' link has been found.' width, height = DownloadFiles.DANGEROUS_HOST_WARNING.get_size() download_file(DownloadFiles.DANGEROUS_HOST_WARNING.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOADS_PANEL_BADREP_COMPLETED.similar(0.7), 10) assert expected is True, '\'"dangerous host" warning\' download file is completed.' expected = exists(DownloadFiles.UNCOMMON, 10) assert expected is True, '\'"uncommon" warning, for .exe\' link has been found.' width, height = DownloadFiles.UNCOMMON.get_size() download_file(DownloadFiles.UNCOMMON.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOADS_PANEL_UNKNOWN_COMPLETED.similar(0.75), 10) assert expected is True, '\'"uncommon" warning, for .exe\' download file is completed.' expected = exists(DownloadFiles.UNCOMMON_HTTPS, 10) assert expected is True, '\'"uncommon" warning, for https .exe\' link has been found.' width, height = DownloadFiles.UNCOMMON_HTTPS.get_size() download_file(DownloadFiles.UNCOMMON_HTTPS.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOADS_PANEL_UNKNOWN1_COMPLETED, 10) assert expected is True, '\'"uncommon" warning, for https .exe\' download file is completed.' expected = exists(DownloadFiles.POTENTIALLY_UNWANTED, 10) assert expected is True, '\'"potentially unwanted app" warning, for .exe\' link has been found.' width, height = DownloadFiles.POTENTIALLY_UNWANTED.get_size() download_file(DownloadFiles.POTENTIALLY_UNWANTED.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOADS_PANEL_PUA_COMPLETED.similar(0.75), 10) assert expected is True, '\'"potentially unwanted app" warning, for .exe\' download file is completed.' # Clear All Downloads click(DownloadManager.SHOW_ALL_DOWNLOADS) expected = exists(Library.TITLE, 10) assert expected is True, 'Library successfully opened.' click(Library.CLEAR_DOWNLOADS) click_window_control('close') downloads_cleanup() # Navigate back to about:preferences. navigate('about:preferences#search') expected = exists(AboutPreferences.ABOUT_PREFERENCE_SEARCH_PAGE_PATTERN, 10) assert expected is True, 'The \'about:preferences#search\' page successfully loaded.' expected = exists(AboutPreferences.FIND_IN_OPTIONS, 10) assert expected is True, '\'Find in Options\' search field is displayed.' click(AboutPreferences.FIND_IN_OPTIONS) paste('dangerous') expected = exists(AboutPreferences.DECEPTIVE_CONTENT_AND_DANGEROUS_SOFTWARE, 10) assert expected is True, '\'Deceptive content and dangerous software\' section is displayed.' expected = region_option_1.exists(AboutPreferences.UNCHECKED_BOX, 10) assert expected is True, '\'Block dangerous and deceptive content\' option is unchecked.' click(AboutPreferences.BLOCK_DANGEROUS_AND_DECEPTIVE_CONTENT) expected = region_option_1.exists(AboutPreferences.CHECKED_BOX, 10) assert expected is True, '\'Block dangerous and deceptive content\' option is checked.' option_2 = find(AboutPreferences.WARN_UNWANTED_UNCOMMON_SOFTWARE) click(AboutPreferences.WARN_UNWANTED_UNCOMMON_SOFTWARE) region_option_2 = Region(option_2.x - 100, option_2.y - 10, 500, 40) expected = region_option_2.exists(AboutPreferences.UNCHECKED_BOX, 10) assert expected is True, '\'Warn you about unwanted and uncommon software\' option is unchecked.' navigate('http://testsafebrowsing.appspot.com/') # Download all items from Desktop Download Warning. expected = exists(DownloadFiles.MALICIOUS, 10) assert expected is True, '\'"malicious" warning, based on content\' link has been found.' width, height = DownloadFiles.MALICIOUS.get_size() download_file(DownloadFiles.MALICIOUS.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.SEVERE_DOWNLOADS_BUTTON, 10) assert expected is True, 'Malicious downloads button is displayed.' click(NavBar.SEVERE_DOWNLOADS_BUTTON) expected = exists(DownloadManager.SHOW_ALL_DOWNLOADS, 10) assert expected is True, 'Downloads panel is displayed.' downloaded_file = find(DownloadFiles.LIBRARY_DOWNLOADS_CONTENT_RED) region_file = Region(downloaded_file.x - 100, downloaded_file.y - 35, 500, 90) expected = region_file.exists(DownloadManager.DownloadsPanel.BLOCKED_DOWNLOAD_ICON, 10) assert expected is True, 'Blocked download icon is displayed and file download is highlighted red.' expected = exists(DownloadFiles.MALICIOUS_HTTPS, 10) assert expected is True, '\'"malicious" warning, based on content with https\' link has been found.' width, height = DownloadFiles.MALICIOUS_HTTPS.get_size() download_file(DownloadFiles.MALICIOUS_HTTPS.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.SEVERE_DOWNLOADS_BUTTON, 10) assert expected is True, 'Malicious downloads button is displayed.' click(NavBar.SEVERE_DOWNLOADS_BUTTON) expected = exists(DownloadManager.SHOW_ALL_DOWNLOADS, 10) assert expected is True, 'Downloads panel is displayed.' downloaded_file = find(DownloadFiles.LIBRARY_DOWNLOADS_CONTENT1_RED.similar(0.7)) region_file = Region(downloaded_file.x - 100, downloaded_file.y - 35, 500, 90) expected = region_file.exists(DownloadManager.DownloadsPanel.BLOCKED_DOWNLOAD_ICON, 10) assert expected is True, 'Blocked download icon is displayed and file download is highlighted red.' expected = exists(DownloadFiles.DANGEROUS_HOST_WARNING, 10) assert expected is True, '\'"dangerous host" warning\' link has been found.' width, height = DownloadFiles.DANGEROUS_HOST_WARNING.get_size() download_file(DownloadFiles.DANGEROUS_HOST_WARNING.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.SEVERE_DOWNLOADS_BUTTON, 10) assert expected is True, 'Malicious downloads button is displayed.' click(NavBar.SEVERE_DOWNLOADS_BUTTON) expected = exists(DownloadManager.SHOW_ALL_DOWNLOADS, 10) assert expected is True, 'Downloads panel is displayed.' downloaded_file = find(DownloadFiles.LIBRARY_DOWNLOADS_BADREP_RED.similar(0.7)) region_file = Region(downloaded_file.x - 100, downloaded_file.y - 35, 500, 90) expected = region_file.exists(DownloadManager.DownloadsPanel.BLOCKED_DOWNLOAD_ICON, 10) assert expected is True, 'Blocked download icon is displayed and file download is highlighted red.' expected = exists(DownloadFiles.UNCOMMON, 10) assert expected is True, '\'"uncommon" warning, for .exe\' link has been found.' width, height = DownloadFiles.UNCOMMON.get_size() download_file(DownloadFiles.UNCOMMON.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOADS_PANEL_UNKNOWN_COMPLETED.similar(0.75), 10) assert expected is True, '\'"uncommon" warning, for .exe\' download file is completed.' expected = exists(DownloadFiles.UNCOMMON_HTTPS, 10) assert expected is True, '\'"uncommon" warning, for https .exe\' link has been found.' width, height = DownloadFiles.UNCOMMON_HTTPS.get_size() download_file(DownloadFiles.UNCOMMON_HTTPS.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOADS_PANEL_UNKNOWN1_COMPLETED, 10) assert expected is True, '\'"uncommon" warning, for https .exe\' download file is completed.' expected = exists(DownloadFiles.POTENTIALLY_UNWANTED, 10) assert expected is True, '\'"potentially unwanted app" warning, for .exe\' link has been found.' width, height = DownloadFiles.POTENTIALLY_UNWANTED.get_size() download_file(DownloadFiles.POTENTIALLY_UNWANTED.target_offset(width / 2 + 10, 0), DownloadFiles.OK) expected = exists(NavBar.DOWNLOADS_BUTTON, 10) assert expected is True, 'Download button found in the page.' click(NavBar.DOWNLOADS_BUTTON) expected = exists(DownloadFiles.DOWNLOADS_PANEL_PUA_COMPLETED.similar(0.75), 10) assert expected is True, '\'"potentially unwanted app" warning, for .exe\' download file is completed.'