Skip to content

[πŸ› Bug]: Pasting images while headless prevent site from loading it.Β #15644

@PaulStSmith

Description

@PaulStSmith

Description

When running Selenium in headless mode, attempting to paste an image (e.g., via clipboard or send_keys) into a web application results in the image not being loaded or processed correctly by the site. The same operation works as expected in non-headless (headed) mode.

Reproducible Code

def send_image_to_clipboard(image_path):
    """
    Copies an image to the Windows clipboard.

    Args:
        image_path (str): Path to the image file to be copied.
    """
    image = Image.open(image_path)
    output = BytesIO()
    image.convert("RGB").save(output, "BMP")
    data = output.getvalue()[14:]
    output.close()

    win32clipboard.OpenClipboard()
    win32clipboard.EmptyClipboard()
    win32clipboard.SetClipboardData(win32clipboard.CF_DIB, data)
    win32clipboard.CloseClipboard()
    time.sleep(1)

send_image_to_clipboard("path/to/image.png")
editor = driver.find_elements(By.CSS_SELECTOR, "div[contenteditable='true']")
editor.send_keys(Keys.Control 'v')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions