Skip to content

[🐛 Bug]: Pasting images while headless prevent site from loading it. #15644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PaulStSmith opened this issue Apr 19, 2025 · 4 comments
Closed
Labels
C-py Python Bindings D-chrome G-chromedriver Requires fixes in ChromeDriver I-defect Something is not working as intended OS-windows

Comments

@PaulStSmith
Copy link

PaulStSmith commented Apr 19, 2025

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')
@PaulStSmith PaulStSmith added A-needs-triaging A Selenium member will evaluate this soon! I-defect Something is not working as intended labels Apr 19, 2025
@selenium-ci
Copy link
Member

@PaulStSmith, thank you for creating this issue. We will troubleshoot it as soon as we can.

Selenium Triage Team: remember to follow the Triage Guide

@cgoldberg cgoldberg added G-chromedriver Requires fixes in ChromeDriver and removed A-needs-triaging A Selenium member will evaluate this soon! labels Apr 19, 2025
@selenium-ci
Copy link
Member

Hi, @PaulStSmith.
This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team.
Feel free to comment the issues that you raise back in this issue. Thank you.

@cgoldberg
Copy link
Contributor

editor.send_keys(Keys.Control 'v')

Sending control keys in Chromium browsers requires a display, so it won't work in headless mode. This is a limitation of ChromeDriver and not something we can fix in Selenium.

@cgoldberg cgoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2025
Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators May 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-py Python Bindings D-chrome G-chromedriver Requires fixes in ChromeDriver I-defect Something is not working as intended OS-windows
Projects
None yet
Development

No branches or pull requests

3 participants