You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this issue with cuprite tests which I don't think we had before.
It seems that the webpage does not resize with the viewport. This causes the web page to be smaller than the viewport.
You can see in the video that the actual page does not resize with the viewport, unlike the other window where the content fits into the viewport (and is responsive).
In my particular case, the tests are failing because one of the alerts is "hidden" outside of the viewport (because the content does not get fitted in the viewport).
This is expected behavior. On every new page, Cuprite sets the window size to window_size (1024脳768 by default) and also fixes the page's viewport at that size with Emulation.setDeviceMetricsOverride. That way innerWidth/innerHeight are exactly window_size and tests see the same page size on every machine. This used to happen in Ferrum too (rubycdp/ferrum#203). Ferrum no longer does it, but Cuprite still does, because tests rely on it.
In headless runs nobody resizes the window, so this has no visible effect. In a visible window (headless: false) it shows up in two ways:
Chrome's toolbar takes up part of the window, but the page stays 768px tall, so its bottom is cut off.
Resizing the window by hand changes only the window. The page stays 1024脳768 and doesn't reflow, which is what your video shows.
Since #339 (in the next release), you can pass window_size: nil to leave the size to Chrome. Then the page follows the window like in a regular browser:
Activity
route commentedon Jun 29, 2024
I think that's Chrome bug, what version are you using now? What version you used previously and when was the last update?
adrianthedev commentedon Jun 29, 2024
It's Chrome Version 126.0.6478.127 (Official Build) (arm64)
And cuprite (0.15.1)
How can I update it?
adrianthedev commentedon Jun 29, 2024
Not sure what I had before. I switched from selenium
Nakilon commentedon Jun 30, 2024
Does the issue disappear if you remove this line? https://github.com/rubycdp/ferrum/blob/99cfa84c56e55bb373da48935d08d5a13df1ad27/lib/ferrum/page.rb#L169
adrianthedev commentedon Jun 30, 2024
Yes. The issue is fixed by removing that line.
The page starts working properly now when resizing the browser.
Thanks!
Nakilon commentedon Jun 30, 2024
I thought it was fixed: rubycdp/ferrum#203
route commentedon Oct 15, 2026
This is expected behavior. On every new page, Cuprite sets the window size to
window_size(1024脳768 by default) and also fixes the page's viewport at that size withEmulation.setDeviceMetricsOverride. That wayinnerWidth/innerHeightare exactlywindow_sizeand tests see the same page size on every machine. This used to happen in Ferrum too (rubycdp/ferrum#203). Ferrum no longer does it, but Cuprite still does, because tests rely on it.In headless runs nobody resizes the window, so this has no visible effect. In a visible window (
headless: false) it shows up in two ways:Since #339 (in the next release), you can pass
window_size: nilto leave the size to Chrome. Then the page follows the window like in a regular browser:Checked in a visible window, resizing it to 1400脳900 by hand:
window_sizewindow_size: nilAdd
browser_options: { "start-maximized" => nil }to start maximized.resize_window_tostill sets an exact size when a test needs one.