Skip to content

Viewport not resizing聽#269

Closed
Closed

Description

@adrianthedev

Hey 馃憢

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).

I'd love to get some help with this.

Thank you!

CleanShot.2024-06-29.at.11.17.34-converted.mp4

Activity

  1. route commented on Jun 29, 2024

    @route
    Member

    I think that's Chrome bug, what version are you using now? What version you used previously and when was the last update?

  2. adrianthedev commented on Jun 29, 2024

    @adrianthedev
    Author

    It's Chrome Version 126.0.6478.127 (Official Build) (arm64)
    And cuprite (0.15.1)

    How can I update it?

  3. adrianthedev commented on Jun 29, 2024

    @adrianthedev
    Author

    Not sure what I had before. I switched from selenium

  4. Nakilon commented on Jun 30, 2024

    @Nakilon
  5. adrianthedev commented on Jun 30, 2024

    @adrianthedev
    Author

    Yes. The issue is fixed by removing that line.
    The page starts working properly now when resizing the browser.

    Thanks!

  6. Nakilon commented on Jun 30, 2024

    @Nakilon

    I thought it was fixed: rubycdp/ferrum#203

  7. route commented on Oct 15, 2026

    @route
    Member

    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:

    Capybara::Cuprite::Driver.new(app, headless: false, window_size: nil)

    Checked in a visible window, resizing it to 1400脳900 by hand:

    Page before Page after resizing the window
    default window_size 1024脳768 1024脳768 (stays fixed)
    window_size: nil 1200脳818 1400脳813 (follows the window)

    Add browser_options: { "start-maximized" => nil } to start maximized. resize_window_to still sets an exact size when a test needs one.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions