Skip to content

Capture Fullpage Screenshot #1459

Open
Open
@F3licity

Description

@F3licity

This is not a bug, but rather a new feature.
Often the browser page is longer that is shown and the user needs to scroll down to see the rest of the page.

Robot Framework often takes a screenshot on failure, but the screenshot captured only shows half of the page and might not include the problematic area.
It would be nice to have a keyword that captures a whole length image.

This is my python script to implement such functionality

def capture_fullpage_screenshot(url):
    """ Creating a Full-Page screenshot.

    Use this keyword for debugging purposes.
    Creates an image called full_page_screenshot.png.
    """
    options = webdriver.ChromeOptions()
    options.add_argument("start-maximized")
    options.add_argument("enable-automation")
    options.add_argument("--headless")
    options.add_argument("--no-sandbox")
    options.add_argument("disable-infobars")
    options.add_argument("--disable-extensions")
    options.add_argument("--disable-gpu")
    driver = webdriver.Chrome(options=options)
    current_window = driver.get_window_size()

    driver.get(url)

    time.sleep(12)

    height = driver.execute_script("return document.body.scrollHeight")
    driver.set_window_size(1920, height)
    driver.save_screenshot("full_page_screenshot.png")

    driver.set_window_size(current_window["width"], current_window["height"])

However, it is not yet properly working, as it does not work inside docker.
And it has a hardcoded file name.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions