-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed as not planned
Closed as not planned
Copy link
Labels
C-pyPython BindingsPython BindingsD-chromeG-chromedriverRequires fixes in ChromeDriverRequires fixes in ChromeDriverI-defectSomething is not working as intendedSomething is not working as intendedOS-windows
Description
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
Labels
C-pyPython BindingsPython BindingsD-chromeG-chromedriverRequires fixes in ChromeDriverRequires fixes in ChromeDriverI-defectSomething is not working as intendedSomething is not working as intendedOS-windows