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

Not using full viewport using browserless 2 docker image #492

Open
bk-one opened this issue Sep 10, 2024 · 1 comment
Open

Not using full viewport using browserless 2 docker image #492

bk-one opened this issue Sep 10, 2024 · 1 comment
Assignees

Comments

@bk-one
Copy link

bk-one commented Sep 10, 2024

If you initialize Ferrum with a window size using remote browserless 2 - the window size is applied, but the viewport is not updated automatically. The DOM is rendered in a 800x600 frame, even if the browser window is set to 1900x1080.

I'm not sure if it's a bug or expected behavior, just leaving this here for reference. The workaround to utilize the full viewport is easy:

page.driver.browser.set_viewport width: 1900, height: 1080

But I had to explicitly add this, to use the full window.

Expected behavior:
The viewport is automatically extended to the window size given when initializing Ferrum. Did not have the issue when using a local chromium, this appeared after switching to browserless 2.

For reference:
Screenshot 2024-09-10 at 11 44 50

@bk-one
Copy link
Author

bk-one commented Sep 20, 2024

Some additional information, maybe helpful.

require 'ferrum'
# using local chromium
browser = Ferrum::Browser.new window_size: [1920, 1080] 
browser.viewport_size
=> [1920, 993]

# using browserless 2 via ws connection
browser = Ferrum::Browser.new window_size: [1920, 1080], ws_url: 'ws://chrome:3000?token=XYZ'
browser.viewport_size
=> [800, 600]

And something seems to be resetting it back to 800, 600

require 'ferrum'
browser = Ferrum::Browser.new window_size: [1920, 1080], ws_url: 'ws://chrome:3000?token=XYZ'
browser.viewport_size
=> [800, 600]
bowser.set_viewport height: 1080, width: 1920
=> {}
browser.viewport_size
=> [1920, 1080]
browser.go_to 'https://github.com'
=> "35732CEB91B12F9DDDB3C1FCCB2DF06B"
browser.viewport_size
=> [800, 600]

However, there seems to be a way to change the default viewport in browserless, by passing launch options to the ws_url. This did the trick for me eventually:

browser = Ferrum::Browser.new window_size: [1920, 1080], ws_url: 'ws://chrome:3000?token=XYZ&launch={"defaultViewport":{"height":1080,"width":1920}}'
browser.viewport_size
=> [1920, 1080]

Still a bit un-intuitive, but not sure if this is related to ferrum or rather to browserless. Keeping this open for reference, though.

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

No branches or pull requests

2 participants