Example #1
0
    class BookmarksOption(object):
        BOOKMARKING_TOOLS = Pattern('bookmarking_tools.png')
        SEARCH_BOOKMARKS = Pattern('search_bookmarks.png')

        class BookmarkingTools(object):
            VIEW_BOOKMARKS_TOOLBAR = Pattern('view_bookmarks_toolbar.png')
            VIEW_BOOKMARKS_SIDEBAR = Pattern('view_bookmarks_sidebar.png')
Example #2
0
def create_region_for_hamburger_menu():
    """Create region for hamburger menu pop up."""

    hamburger_menu_pattern = NavBar.HAMBURGER_MENU
    try:
        wait(hamburger_menu_pattern, 10)
        click(hamburger_menu_pattern)
        time.sleep(0.5)
        sign_in_to_sync = Pattern('sign_in_to_sync.png')
        if OSHelper.is_linux():
            quit_menu_pattern = Pattern('quit.png')
            return RegionUtils.create_region_from_patterns(None, sign_in_to_sync,
                                                           quit_menu_pattern, None,
                                                           padding_right=20)
        elif OSHelper.is_mac():
            help_menu_pattern = Pattern('help.png')
            return RegionUtils.create_region_from_patterns(None, sign_in_to_sync,
                                                           help_menu_pattern, None,
                                                           padding_right=20)
        else:
            exit_menu_pattern = Pattern('exit.png')
            return RegionUtils.create_region_from_patterns(None, sign_in_to_sync,
                                                           exit_menu_pattern, None,
                                                           padding_right=20)
    except (FindError, ValueError):
        raise APIHelperError(
            'Can\'t find the hamburger menu in the page, aborting test.')
Example #3
0
class ContentBlockingTour(object):
    DIFFERENCES_TO_EXPECT_LABEL = Pattern('differences_to_expect_label.png')
    NEXT_BUTTON_SECOND_TOUR_STEP = Pattern('next_button_second_tour_step.png')
    TURN_OFF_BLOCKING_LABEL = Pattern(
        'ui_tour_tooltip_title_turn_off_blocking.png')
    GOT_IT_BUTTON = Pattern('got_it_button.png')
    RESTART_TOUR_BUTTON = Pattern('restart_tour_button.png')
Example #4
0
def maximize_window():
    """Maximize the browser window to fill the screen.

    This is NOT Full Screen mode.
    """
    if OSHelper.is_mac():
        # There is no keyboard shortcut for this on Mac. We'll do it the old fashioned way.
        # This image is of the three window control buttons at top left of the window.
        # We have to resize the window to ensure maximize works properly in all cases.
        window_controls_pattern = Pattern('window_controls.png')
        controls_location = find(window_controls_pattern)
        xcoord = controls_location.x
        ycoord = controls_location.y
        width, height = window_controls_pattern.get_size()
        drag_start = Location(xcoord + 70, ycoord + 5)
        drag_end = Location(xcoord + 75, ycoord + 5)
        Mouse().drag_and_drop(drag_start, drag_end, duration=0.1)

        # Alt key changes maximize button from full screen to maximize window.
        maximize_button = window_controls_pattern.target_offset(
            width / 2 - 3, 0)
        key_down(Key.ALT)
        click(maximize_button)
        key_up(Key.ALT)

    elif OSHelper.is_windows():
        type(text=Key.UP, modifier=KeyModifier.WIN)
    else:
        type(text=Key.UP, modifier=[KeyModifier.CTRL, KeyModifier.META])
    time.sleep(Settings.DEFAULT_UI_DELAY)
Example #5
0
    class Views(object):
        SHOW_COLUMNS = Pattern('viewColumns.png')

        class ShowColumns(object):
            NAME = Pattern('menucol_placesContentTitle.png')
            TAGS = Pattern('menucol_placesContentTags.png')
            LOCATION = Pattern('menucol_placesContentUrl.png')
            MOST_RECENT_VISIT = Pattern('menucol_placesContentDate.png')
            VISIT_COUNT = Pattern('menucol_placesContentVisitCount.png')
            ADDED = Pattern('menucol_placesContentDateAdded.png')
            LAST_MODIFIED = Pattern('menucol_placesContentLastModified.png')

        SORT = Pattern('viewSort.png')

        class Sort(object):
            UNSORTED = Pattern('viewUnsorted.png')
            SORT_BY_NAME = Pattern('sort_by_menucol_placesContentTitle.png')
            SORT_BY_TAGS = Pattern('sort_by_menucol_placesContentTags.png')
            SORT_BY_LOCATION = Pattern('sort_by_menucol_placesContentUrl.png')
            SORT_BY_MOST_RECENT_VISIT = Pattern(
                'sort_by_menucol_placesContentDate.png')
            SORT_BY_VISIT_COUNT = Pattern(
                'sort_by_menucol_placesContentVisitCount.png')
            SORT_BY_ADDED = Pattern(
                'sort_by_menucol_placesContentDateAdded.png')
            SORT_BY_LAST_MODIFIED = Pattern(
                'sort_by_menucol_placesContentLastModified.png')
            AZ_SORT_ORDER = Pattern('viewSortAscending.png')
            ZA_SORT_ORDER = Pattern('viewSortDescending.png')
Example #6
0
 class Downloads(object):
     SHOW_DOWNLOADS_FOLDER = Pattern(
         'appmenu_library_downloads_show_button_show_downloads_folder.png')
     PANEL_HEADER_DOWNLOADS = Pattern('panel_header_downloads.png')
     SHOW_ALL_DOWNLOADS = Pattern('library_menu_downloads_more.png')
     FILE_MOVED_OR_MISSING = Pattern('file_moved_or_missing.png')
     EXTRA_SMALL_FILE_5MB_ZIP = Pattern('5mb_zip.png')
Example #7
0
class SidebarBookmarks(object):
    BOOKMARKS_HEADER = Pattern('bookmarks_header.png')
    BOOKMARKS_MENU = Pattern('sidebar_bookmarks_menu.png')
    BOOKMARKS_MENU_SELECTED = Pattern('sidebar_bookmarks_menu_selected.png')
    OTHER_BOOKMARKS = Pattern('sidebar_other_bookmarks.png')
    BOOKMARKS_TOOLBAR_MENU = Pattern('bookmarks_toolbar_menu.png')

    class BookmarksToolbar(object):
        MOST_VISITED = Pattern('bookmarks_toolbar_most_visited.png')
Example #8
0
    class ImportAndBackup(object):
        BACKUP = Pattern('backupBookmarks.png')
        RESTORE = Pattern('fileRestoreMenu.png')

        class Restore(object):
            CHOOSE_FILE = Pattern('restoreFromFile.png')

        IMPORT_BOOKMARKS_FROM_HTML = Pattern('fileImport.png')
        EXPORT_BOOKMARKS_FROM_HTML = Pattern('fileExport.png')
        IMPORT_DATA_FROM_ANOTHER_BROWSER = Pattern('browserImport.png')
Example #9
0
 class DownloadState(object):
     COMPLETED = Pattern('download_details_completed.png')
     CANCELED = Pattern('download_details_canceled.png')
     FAILED = Pattern('download_details_failed.png')
     PROGRESS = Pattern('download_details_left_size.png')
     PAUSED = Pattern('download_details_paused.png')
     RETRY_DOWNLOAD = Pattern('download_details_retry_download.png')
     OPEN_FILE = Pattern('download_details_open_file.png')
     SPEED_PER_SECOND = Pattern('download_details_speed_per_second.png')
     MISSING_FILE = Pattern('download_details_file_moved_or_missing.png')
     TEMPORARY_BLOCKED = Pattern('download_details_temporary_blocked.png')
Example #10
0
class LibraryMenu(object):
    HISTORY_BUTTON = Pattern('library_history_button.png')
    BOOKMARKS_OPTION = Pattern('library_menu_bookmarks_option.png')
    DOWNLOADS = Pattern('appmenu_library_downloads_button.png')

    class BookmarksOption(object):
        BOOKMARKING_TOOLS = Pattern('bookmarking_tools.png')
        SEARCH_BOOKMARKS = Pattern('search_bookmarks.png')

        class BookmarkingTools(object):
            VIEW_BOOKMARKS_TOOLBAR = Pattern('view_bookmarks_toolbar.png')
            VIEW_BOOKMARKS_SIDEBAR = Pattern('view_bookmarks_sidebar.png')
Example #11
0
def open_clear_recent_history_window():
    return [
        access_and_check_pattern(NavBar.LIBRARY_MENU, '\"Library menu\"',
                                 Pattern('library_history_button.png'),
                                 'click'),
        access_and_check_pattern(Pattern('library_history_button.png'),
                                 '\"History menu\"',
                                 Pattern('clear_recent_history.png'), 'click'),
        access_and_check_pattern(
            Pattern('clear_recent_history.png'), '\"Clear recent History\"',
            Pattern('sanitize_dialog_non_everything_title.png'), 'click')
    ]
Example #12
0
class FindToolbar(object):
    FIND_CLOSEBUTTON = Pattern('find_closebutton.png')
    FINDBAR_TEXTBOX = Pattern('findbar_textbox.png')
    FIND_PREVIOUS = Pattern('find_previous.png')
    FIND_NEXT = Pattern('find_next.png')
    HIGHLIGHT = Pattern('highlight.png')
    FIND_CASE_SENSITIVE = Pattern('find_case_sensitive.png')
    FIND_ENTIRE_WORD = Pattern('find_entire_word.png')
    QUICK_FIND_LABEL = Pattern('quick_find_label.png')
    QUICK_FIND_LINKS_ONLY_LABEL = Pattern('quick_find_links_only_label.png')
    FIND_STATUS_PHRASE_NOT_FOUND = Pattern(
        'findbar_find_status_phrase_not_found.png')
Example #13
0
        class ViewBy(object):
            VIEW_BY_SITE = Pattern('by_site.png')
            VIEW_BY_LAST_VISITED = Pattern('by_last_visited.png')
            VIEW_BY_DATE_AND_SITE = Pattern('by_date_and_site.png')
            VIEW_BY_DATE = Pattern('by_date.png')
            VIEW_BY_MOST_VISITED = Pattern('by_most_visited.png')

            # Checked view menu items
            VIEW_BY_SITE_CHECKED = Pattern('by_site_checked.png')
            VIEW_BY_LAST_VISITED_CHECKED = Pattern('by_last_visited_checked.png')
            VIEW_BY_DATE_AND_SITE_CHECKED = Pattern('by_date_and_site_checked.png')
            VIEW_BY_DATE_CHECKED = Pattern('by_date_checked.png')
            VIEW_BY_MOST_VISITED_CHECKED = Pattern('by_most_visited_checked.png')
Example #14
0
def create_region_from_image(image):
    """Create region starting from a pattern.

    :param image: Pattern used to create a region.
    :return: None.
    """
    try:
        from mattapi.api.rectangle import Rectangle
        from mattapi.api.enums import Alignment
        m = image_find(image)
        if m:
            sync_pattern = Pattern('sync_hamburger_menu.png')
            sync_width, sync_height = sync_pattern.get_size()
            sync_image = image_find(sync_pattern)
            top_left = Rectangle(sync_image.x, sync_image.y, sync_width, sync_width). \
                apply_alignment(Alignment.TOP_RIGHT)
            if OSHelper.is_mac():
                exit_pattern = Pattern('help_hamburger_menu.png')
            else:
                exit_pattern = Pattern('exit_hamburger_menu.png')
            exit_width, exit_height = exit_pattern.get_size()
            exit_image = image_find(exit_pattern)
            bottom_left = Rectangle(exit_image.x, exit_image.y, exit_width, exit_height). \
                apply_alignment(Alignment.BOTTOM_RIGHT)

            x0 = top_left.x + 2
            y0 = top_left.y
            height = bottom_left.y - top_left.y
            width = Screen().width - top_left.x - 2
            region = Region(x0, y0, width, height)
            return region
        else:
            raise APIHelperError('No matching found.')
    except FindError:
        raise APIHelperError('Image not present.')
Example #15
0
def find_in_region_from_pattern(outer_pattern: Pattern, inner_pattern: Pattern,
                                outer_pattern_timeout=Settings.auto_wait_timeout,
                                inner_pattern_timeout=Settings.auto_wait_timeout):
    """ Finds pattern in region created from another pattern
    :param outer_pattern: Pattern for region creation
    :param inner_pattern: Pattern to find in region
    :param outer_pattern_timeout: Time to finding outer_pattern
    :param inner_pattern_timeout: Time to finding inner_pattern,
    :return: Boolean. True if inner_pattern found in outer_pattern region
    :raises: ValueError and APIHelperError
    """
    if not isinstance(outer_pattern, Pattern) or not isinstance(inner_pattern, Pattern):
        raise ValueError(INVALID_GENERIC_INPUT)

    try:
        wait(outer_pattern, outer_pattern_timeout)
        logger.debug('Outer pattern found.')

    except FindError:
        raise APIHelperError('Can\'t find the outer pattern.')

    width, height = outer_pattern.get_size()
    region = Region(image_find(outer_pattern).x, image_find(outer_pattern).y, width, height)

    pattern_found = exists(inner_pattern, inner_pattern_timeout, region=region)

    return pattern_found
Example #16
0
def remove_zoom_indicator_from_toolbar():
    """Remove the zoom indicator from toolbar by clicking on the 'Remove from
    Toolbar' button.
    """

    zoom_control_toolbar_decrease_pattern = NavBar.ZOOM_OUT
    remove_from_toolbar_pattern = Pattern('remove_from_toolbar.png')

    try:
        wait(zoom_control_toolbar_decrease_pattern, FirefoxSettings.FIREFOX_TIMEOUT)
        logger.debug('\'Decrease\' zoom control found.')
        right_click(zoom_control_toolbar_decrease_pattern)
    except FindError:
        raise APIHelperError(
            'Can\'t find the \'Decrease\' zoom control button in the page, \
            aborting.')

    try:
        wait(remove_from_toolbar_pattern, FirefoxSettings.FIREFOX_TIMEOUT)
        logger.debug('\'Remove from Toolbar\' option found.')
        click(remove_from_toolbar_pattern)
    except FindError:
        raise APIHelperError(
            'Can\'t find the \'Remove from Toolbar\' option in the page, \
            aborting.')

    try:
        wait_vanish(zoom_control_toolbar_decrease_pattern, FirefoxSettings.FIREFOX_TIMEOUT)
    except FindError:
        raise APIHelperError(
            'Zoom indicator not removed from toolbar, aborting.')
Example #17
0
    class ForgetLast(object):
        FORGET_TIMEFRAME_TITLE = Pattern(
            'panelui_panic_button_success_icon.png')

        LAST_FIVE_MINUTES = Pattern('panelui_panic_5min.png')
        LAST_TWO_HOURS = Pattern('panelui_panic_2hr.png')
        LAST_24_HOURS = Pattern('panelui_panic_day.png')

        # Selected items
        LAST_FIVE_MINUTES_SELECTED = Pattern('panelui_panic_5min_selected.png')
        LAST_TWO_HOURS_SELECTED = Pattern('panelui_panic_2hr_selected.png')
        LAST_24_HOURS_SELECTED = Pattern('panelui_panic_day_selected.png')

        FORGET_BUTTON = Pattern('panelui_panic_view_button.png')
        SUCCESS_FORGET_MSG = Pattern('panelui_panic_button_success_msg.png')
        CLOSE_FORGET_PANEL_BUTTON = Pattern(
            'panelui_panic_success_close_button.png')
Example #18
0
        class TimeRange(object):
            LAST_HOUR = Pattern('last_hour.png')
            LAST_TWO_HOURS = Pattern('last_two_hours.png')
            LAST_FOUR_HOURS = Pattern('last_four_hours.png')
            TODAY = Pattern('today.png')
            EVERYTHING = Pattern('everything.png')

            # Focused time ranges.
            CLEAR_CHOICE_LAST_HOUR = Pattern(
                'sanitize_duration_choice_last_hour.png')
            CLEAR_CHOICE_LAST_TWO_HOURS = Pattern(
                'sanitize_duration_choice_last_two_hours.png')
            CLEAR_CHOICE_LAST_FOUR_HOURS = Pattern(
                'sanitize_duration_choice_last_four_hours.png')
            CLEAR_CHOICE_TODAY = Pattern('sanitize_duration_choice_today.png')
            CLEAR_CHOICE_EVERYTHING = Pattern(
                'sanitize_duration_choice_everything.png')
Example #19
0
def click_cancel_button():
    """Click cancel button."""
    cancel_button_pattern = Pattern('cancel_button.png').similar(.7)
    try:
        wait(cancel_button_pattern, 10)
        logger.debug('Cancel button found.')
        click(cancel_button_pattern)
    except FindError:
        raise APIHelperError('Can\'t find the cancel button, aborting.')
Example #20
0
    class Themes(object):
        DARK_THEME = Pattern('dark_theme.png')
        LIGHT_THEME = Pattern('light_theme.png')
        DEFAULT_THEME = Pattern('default_theme.png')

        ACTION_BUTTON = Pattern('action_button.png')

        ENABLE_BUTTON = Pattern('enable_button.png')
        DISABLE_BUTTON = Pattern('disable_button.png')
        IRIS_TAB_LIGHT_OR_DEFAULT_THEME = Pattern('iris_tab_light_theme.png').similar(0.75)
        IRIS_TAB_DARK_THEME = Pattern('iris_tab_dark_theme.png').similar(0.75)
Example #21
0
 class ShowColumns(object):
     NAME = Pattern('menucol_placesContentTitle.png')
     TAGS = Pattern('menucol_placesContentTags.png')
     LOCATION = Pattern('menucol_placesContentUrl.png')
     MOST_RECENT_VISIT = Pattern('menucol_placesContentDate.png')
     VISIT_COUNT = Pattern('menucol_placesContentVisitCount.png')
     ADDED = Pattern('menucol_placesContentDateAdded.png')
     LAST_MODIFIED = Pattern('menucol_placesContentLastModified.png')
Example #22
0
def close_customize_page():
    """Close the 'Customize...' page by pressing the 'Done' button."""
    customize_done_button_pattern = Pattern('customize_done_button.png')
    try:
        wait(customize_done_button_pattern, 10)
        logger.debug('Done button found.')
        click(customize_done_button_pattern)
    except FindError:
        raise APIHelperError(
            'Can\'t find the Done button in the page, aborting.')
Example #23
0
 class DownloadsContextMenu(object):
     OPEN_CONTAINING_FOLDER = Pattern(
         'downloads_open_containing_folder.png')
     CLEAR_PREVIEW_PANEL = Pattern('downloads_clear_preview_panel.png')
     COPY_DOWNLOAD_LINK = Pattern('downloads_copy_download_link.png')
     GO_TO_DOWNLOAD_PAGE = Pattern('downloads_go_to_download_page.png')
     REMOVE_FROM_HISTORY = Pattern('downloads_remove_from_history.png')
     PAUSE = Pattern('downloads_pause.png')
     RESUME = Pattern('downloads_resume.png')
Example #24
0
def select_throttling(option):
    open_web_console()

    try:
        wait(Pattern('network.png'), 10)
        click(Pattern('network.png'))
    except FindError:
        raise APIHelperError(
            'Can\'t find the network menu in the page, aborting test.')

    try:
        wait(Pattern('no_throttling.png'), 10)
        click(Pattern('no_throttling.png'))
    except FindError:
        raise APIHelperError(
            'Can\'t find the throttling menu in the page, aborting test.')

    for i in range(option + 1):
        type(Key.DOWN)
    type(Key.ENTER)
Example #25
0
def _get_pattern_click_location(ps: Pattern,
                                region: Rectangle = None,
                                align: Alignment = None):
    """Returns the click location based on the pattern/string found location and alignment."""
    if align is None:
        align = Alignment.CENTER

    width, height = ps.get_size()
    find_location = image_find(ps, region=region)

    if find_location is None:
        raise FindError('Unable to find pattern {}'.format(ps.get_filename()))

    if ps.get_target_offset():
        target_offset = ps.get_target_offset()
        find_location.x += target_offset.x
        find_location.y += target_offset.y

    rect = Rectangle(find_location.x, find_location.y, width, height)
    return rect.apply_alignment(align)
Example #26
0
def confirm_firefox_launch(image=None):
    """Waits for firefox to exist by waiting for the iris logo to be present.
    :param image: Pattern to confirm Firefox launch
    :return: None.
    """
    if image is None:
        image = Pattern('iris_logo.png')

    try:
        wait(image, 60)
    except Exception:
        raise APIHelperError('Can\'t launch Firefox - aborting test run.')
Example #27
0
class MainWindow(object):
    if OSHelper.is_mac():
        MAIN_WINDOW_CONTROLS = Pattern('main_window_controls.png')
        UNHOVERED_MAIN_RED_CONTROL = Pattern('unhovered_main_red_control.png')
        HOVERED_MAIN_RED_CONTROL = Pattern('hovered_red_main_control.png')
    else:
        CLOSE_BUTTON = Pattern('main_close_control.png')
        MINIMIZE_BUTTON = Pattern('main_minimize_control.png')
        MAXIMIZE_BUTTON = Pattern('main_maximize_control.png')
        RESIZE_BUTTON = Pattern('main_resize_control.png')
Example #28
0
def restore_window_from_taskbar(option=None):
    """Restore firefox from task bar."""
    if OSHelper.is_mac():
        try:
            click(Pattern('main_menu_window.png'))
            if option == "browser_console":
                click(Pattern('window_browser_console.png'))
            else:
                click(Pattern('window_firefox.png'))
        except FindError:
            raise APIHelperError('Restore window from taskbar unsuccessful.')
    elif OSHelper.get_os_version() == 'win7':
        try:
            click(Pattern('firefox_start_bar.png'))
            if option == "library_menu":
                click(Pattern('firefox_start_bar_library.png'))
            if option == "browser_console":
                click(Pattern('firefox_start_bar_browser_console.png'))
        except FindError:
            raise APIHelperError('Restore window from taskbar unsuccessful.')

    else:
        type(text=Key.TAB, modifier=KeyModifier.ALT)
        if OSHelper.is_linux():
            Mouse().move(Location(0, 50))
    time.sleep(Settings.DEFAULT_UI_DELAY)
Example #29
0
class Utils(object):
    # Checkbox.
    CHECKEDBOX = Pattern('checked_box.png')
    UNCHECKEDBOX = Pattern('unchecked_box.png')

    # Back Arrow.
    LIBRARY_BACK_BUTTON = Pattern('subview_button_back.png')

    TOP_SITES = Pattern('top_sites.png')

    SAVE_BUTTON_GOOGLE = Pattern('save_button_google.png')

    # Folder view.
    NEW_FOLDER = Pattern('new_folder.png')
    NEW_FOLDER_HIGHLIGHTED = Pattern('new_folder_highlighted.png')
    SELECT_FOLDER = Pattern('select_folder.png')
    NEW_DOWNLOADS_FOLDER_HIGHLIGHTED = Pattern(
        'new_downloads_folder_highlighted.png')
Example #30
0
class HamburgerMenu(object):

    ADDONS = Pattern('hamburger_menu_addons.png')
    SAVE_OPTIONS = Pattern('hamburger_menu_save_options.png')
    NEW_WINDOW = Pattern('hamburger_menu_new_window.png')
    HAMBURGER_MENU_ZOOM_INDICATOR = Pattern('appMenu_zoom_controls.png')
    EDIT_BUTTONS_BELOW_ZOOM_BUTTONS = Pattern(
        'edit_buttons_below_zoom_buttons.png')
    HAMBUREGR_MENU = Pattern('panelui_menu_button.png')
    HAMBURGER_MENU_FIND_IN_PAGE_PATTERN = Pattern(
        'hamburger_menu_find_in_page_pattern.png')