Skip to content

[🐛 Bug]: Incorrect screenshot size in Ubuntu 24.04 #14660

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
GergelyKalmar opened this issue Oct 26, 2024 · 6 comments
Closed

[🐛 Bug]: Incorrect screenshot size in Ubuntu 24.04 #14660

GergelyKalmar opened this issue Oct 26, 2024 · 6 comments
Labels
I-defect Something is not working as intended J-awaiting answer Question asked of user; a reply moves it to triage again

Comments

@GergelyKalmar
Copy link

What happened?

We've migrated from Ubuntu 20.04 to Ubuntu 24.04, and suddenly our Selenium screenshot sizes changed.

It seems that the initial window size now includes the search bar / bookmarks bar (and potentially other elements like notification bars), therefore the actual space left for the page content is smaller than the specified window size, even in headless mode. (Tried both the old and new headless modes, the results are the same.)

While the window size is 1800x900 pixels as specified (and as returned by get_window_size), the actual screenshot size is only 1800x708 pixels. Occasionally (for some tests) we also observed widths that were different from the originally specified widths.

It does seem like this might be an issue with Chrome / ChromeDriver, but I wanted to open an issue here as well to see if there's maybe something we can do as a workaround in the meantime.

How can we reproduce the issue?

#!/usr/bin/env python3
import logging

from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.webdriver import WebDriver

logger = logging.getLogger('selenium')
logger.setLevel(logging.DEBUG)
logging.basicConfig(level=logging.DEBUG)

chrome_path = '{...}/chrome/130.0.6723.69/chrome'
chromedriver_path = '{...}/chromedriver/130.0.6723.69/chromedriver'
screenshot_destination = '{...}/selenium-test/test.png'

width = 1800
height = 900

service = Service(executable_path=chromedriver_path)
options = Options()
options.binary_location = chrome_path
options.add_argument('--headless=new')
options.add_argument(f'--window-size={width},{height}')

driver = WebDriver(options=options, service=service)
print(driver.get_window_size())
driver.get_screenshot_as_file(screenshot_destination)

Relevant log output

DEBUG:selenium.webdriver.common.driver_finder:Skipping Selenium Manager; path to chrome driver specified in Service class: .../chromedriver/130.0.6723.69/chromedriver
DEBUG:selenium.webdriver.common.service:Started executable: `.../chromedriver/130.0.6723.69/chromedriver` in a child process with pid: 9673 using 0 to output -3
DEBUG:selenium.webdriver.remote.remote_connection:POST http://localhost:37079/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'chrome', 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'goog:chromeOptions': {'extensions': [], 'binary': '.../chrome/130.0.6723.69/chrome', 'args': ['--headless=new', '--window-size=1800,900']}}}}
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): localhost:37079
DEBUG:urllib3.connectionpool:http://localhost:37079 "POST /session HTTP/11" 200 0
DEBUG:selenium.webdriver.remote.remote_connection:Remote response: status=200 | data={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"130.0.6723.69","chrome":{"chromedriverVersion":"130.0.6723.69 (3ec172b971b9478c515a58f591112c5c23fa4965-refs/branch-heads/6723@{#1452})","userDataDir":"/tmp/.org.chromium.Chromium.2zos6E"},"fedcm:accounts":true,"goog:chromeOptions":{"debuggerAddress":"localhost:39321"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"linux","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":true,"webauthn:extension:largeBlob":true,"webauthn:extension:minPinLength":true,"webauthn:extension:prf":true,"webauthn:virtualAuthenticators":true},"sessionId":"714b6a83442847ecbccee4eb7ea89edd"}} | headers=HTTPHeaderDict({'Content-Length': '848', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:selenium.webdriver.remote.remote_connection:Finished Request
DEBUG:selenium.webdriver.remote.remote_connection:GET http://localhost:37079/session/714b6a83442847ecbccee4eb7ea89edd/window/rect {}
DEBUG:urllib3.connectionpool:http://localhost:37079 "GET /session/714b6a83442847ecbccee4eb7ea89edd/window/rect HTTP/11" 200 0
DEBUG:selenium.webdriver.remote.remote_connection:Remote response: status=200 | data={"value":{"height":900,"width":1800,"x":10,"y":10}} | headers=HTTPHeaderDict({'Content-Length': '51', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:selenium.webdriver.remote.remote_connection:Finished Request
{'width': 1800, 'height': 900}
DEBUG:selenium.webdriver.remote.remote_connection:GET http://localhost:37079/session/714b6a83442847ecbccee4eb7ea89edd/screenshot {}
DEBUG:urllib3.connectionpool:http://localhost:37079 "GET /session/714b6a83442847ecbccee4eb7ea89edd/screenshot HTTP/11" 200 0
DEBUG:selenium.webdriver.remote.remote_connection:Remote response: status=200 | data={"value":"..."} | headers=HTTPHeaderDict({'Content-Length': '7224', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:selenium.webdriver.remote.remote_connection:Finished Request

Operating System

Ubuntu 24.04

Selenium version

Python 3.12

What are the browser(s) and version(s) where you see this issue?

Chrome for Testing 130.0.6723.69

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 130.0.6723.69

Are you using Selenium Grid?

No

@GergelyKalmar GergelyKalmar added I-defect Something is not working as intended A-needs-triaging A Selenium member will evaluate this soon! labels Oct 26, 2024
Copy link

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


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@shbenzer
Copy link
Contributor

@harsha509 Could this be related to tests/actions_api/test_mouse.py::test_move_by_offset_from_viewport_origin_ab being flaky recently?

Copy link

This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the J-stale Applied to issues that become stale, and eventually closed. label Apr 27, 2025
@GergelyKalmar
Copy link
Author

Not stale, the problem still exists. The window size is flaky regardless of how it is specified.

@github-actions github-actions bot removed the J-stale Applied to issues that become stale, and eventually closed. label Apr 28, 2025
@titusfortner
Copy link
Member

Can you try with Firefox and see if it has the same inconsistencies? Most likely this is a chromedriver issue.

@titusfortner titusfortner added J-awaiting answer Question asked of user; a reply moves it to triage again and removed A-needs-triaging A Selenium member will evaluate this soon! labels Apr 28, 2025
Copy link

This issue was closed because we did not receive any additional information after 14 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-defect Something is not working as intended J-awaiting answer Question asked of user; a reply moves it to triage again
Projects
None yet
Development

No branches or pull requests

3 participants