Skip to content
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

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

Open
GergelyKalmar opened this issue Oct 26, 2024 · 2 comments
Open

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

GergelyKalmar opened this issue Oct 26, 2024 · 2 comments

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

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants