Ejemplo n.º 1
0
def restore_window_control(window_type):
    """Click on restore window control.

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

    if window_type == 'auxiliary':
        if OSHelper.is_mac():
            key_down(Key.ALT)
            width, height = AuxiliaryWindow.AUXILIARY_WINDOW_CONTROLS.get_size()
            click(AuxiliaryWindow.AUXILIARY_WINDOW_CONTROLS.target_offset(width - 10, height / 2),
                  align=Alignment.TOP_LEFT)
            key_up(Key.ALT)
        else:
            if OSHelper.is_linux():
                reset_mouse()
            click(AuxiliaryWindow.ZOOM_RESTORE_BUTTON)
    else:
        if OSHelper.is_mac():
            key_down(Key.ALT)
            width, height = MainWindow.MAIN_WINDOW_CONTROLS.get_size()
            click(MainWindow.MAIN_WINDOW_CONTROLS.target_offset(width - 10, height / 2), align=Alignment.TOP_LEFT)
            key_up(Key.ALT)
        else:
            if OSHelper.is_linux():
                reset_mouse()
            click(MainWindow.RESIZE_BUTTON)
Ejemplo n.º 2
0
def zoom_with_mouse_wheel(nr_of_times=1, zoom_type=None):
    """Zoom in/Zoom out using the mouse wheel.

    :param nr_of_times: Number of times the 'zoom in'/'zoom out' action should
    take place.
    :param zoom_type: Type of the zoom action('zoom in'/'zoom out') intended to
    be performed.
    :return: None.
    """

    # MAC needs doubled number of mouse wheels to zoom in correctly.
    if OSHelper.is_mac():
        nr_of_times *= 2

    # Move focus in the middle of the page to be able to use the scroll.

    Mouse().move(Location(Screen.SCREEN_WIDTH // 4, Screen.SCREEN_HEIGHT // 2))

    for i in range(nr_of_times):
        if OSHelper.is_mac():
            key_down('command')

        else:
            key_down('ctrl')

        Mouse().scroll(dy=zoom_type, dx=0)
        if OSHelper.is_mac():
            key_up('command')

        else:
            key_up('ctrl')

        time.sleep(Settings.DEFAULT_UI_DELAY)
    Mouse().move(Location(0, 0))
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
def open_firefox_menu():
    """
    Opens Firefox top menu
    """
    if OSHelper.is_linux():
        key_down(Key.ALT)
        time.sleep(0.5)
        key_up(Key.ALT)
    elif OSHelper.is_windows():
        type(Key.ALT)