Пример #1
0
def maximize_window():
    """Maximize the browser window to fill the screen.

    This is NOT Full Screen mode.
    """
    if Settings.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)
        drag_drop(drag_start, drag_end, 0.1)

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

    elif Settings.is_windows():
        type(text=Key.UP, modifier=KeyModifier.WIN)
    else:
        type(text=Key.UP, modifier=KeyModifier.CTRL + KeyModifier.META)
    # Wait to allow window to be maximized.
    time.sleep(Settings.UI_DELAY)
Пример #2
0
def maximize_window():
    """Maximize the browser window to fill the screen.

    This is NOT Full Screen mode.
    """
    if Settings.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.
        maximized_browser_pattern = Pattern('maximized_browser.png')
        maximized_browser_width, maximized_browser_height = get_image_size(
            maximized_browser_pattern)
        region = Region(0, 0, maximized_browser_width + 50,
                        maximized_browser_height + 50)

        try:
            region.find(maximized_browser_pattern.similar(0.95))
            logger.debug('Window is already maximized.')
        except (FindError, ValueError):
            logger.debug('Window is not maximized.')
            window_controls_pattern = Pattern('window_controls.png')
            width, height = get_image_size(window_controls_pattern)
            maximize_button = window_controls_pattern.target_offset(
                width - 10, height / 2)

            # Alt key changes maximize button from full screen to maximize window.
            key_down(Key.ALT)
            click(maximize_button)
            key_up(Key.ALT)

    elif Settings.is_windows():
        type(text=Key.UP, modifier=KeyModifier.WIN)
    else:
        type(text=Key.UP, modifier=KeyModifier.CTRL + KeyModifier.META)
    # Wait to allow window to be maximized.
    time.sleep(Settings.UI_DELAY)