-
Notifications
You must be signed in to change notification settings - Fork 6
Configurable viewport docs #76
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d719d69
Configurable viewport docs
hiroTamada 2c577b1
Make viewport optional
hiroTamada e2c562c
moar
hiroTamada bc3720c
moar
hiroTamada 31a9c80
moar
hiroTamada f782e2f
moar
hiroTamada 7d09d4e
docs: update code samples from OpenAPI
github-actions[bot] d3d32fd
Update browser-use.mdx
dprevoznik ece821b
moar
hiroTamada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| --- | ||
| title: "Viewports" | ||
| description: "Configure browser viewport size and refresh rate for your automations" | ||
| --- | ||
|
|
||
| Kernel browsers allow you to configure the viewport size and refresh rate when creating a browser session. The viewport configuration determines the initial browser window dimensions and display refresh rate. The refresh rate can be explicitly specified or automatically determined based on the width and height if they match a supported configuration. | ||
|
|
||
| ## Setting viewport configuration | ||
|
|
||
| You can configure the viewport when creating a browser by specifying the `viewport` parameter with `width` and `height`. The `refresh_rate` is optional and will be automatically determined from the dimensions if they match a supported configuration: | ||
|
|
||
| <CodeGroup> | ||
|
|
||
| ```typescript Typescript/Javascript | ||
| // Explicitly specify refresh rate | ||
| const kernelBrowser = await kernel.browsers.create({ | ||
| viewport: { | ||
| width: 1920, | ||
| height: 1080, | ||
| refresh_rate: 25 | ||
| } | ||
| }); | ||
|
|
||
| // Auto-determine refresh rate from dimensions (25Hz for 1920x1080) | ||
| const kernelBrowserAuto = await kernel.browsers.create({ | ||
| viewport: { | ||
| width: 1920, | ||
| height: 1080 | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| ```python Python | ||
| # Explicitly specify refresh rate | ||
| kernel_browser = client.browsers.create( | ||
| viewport={ | ||
| "width": 1920, | ||
| "height": 1080, | ||
| "refresh_rate": 25 | ||
| } | ||
| ) | ||
|
|
||
| # Auto-determine refresh rate from dimensions (25Hz for 1920x1080) | ||
| kernel_browser_auto = client.browsers.create( | ||
| viewport={ | ||
| "width": 1920, | ||
| "height": 1080 | ||
| } | ||
| ) | ||
| ``` | ||
|
|
||
| </CodeGroup> | ||
|
|
||
| ## Supported viewport configurations | ||
|
|
||
| Kernel supports specific viewport configurations. The server will reject unsupported combinations. When you provide width and height without specifying refresh_rate, it will be automatically determined if the dimensions match one of the supported resolutions exactly. The following resolutions are supported: | ||
|
|
||
| | Resolution | Width | Height | Refresh Rate | | ||
| |------------|-------|--------|--------------| | ||
| | QHD | 2560 | 1440 | 10 Hz | | ||
| | Full HD | 1920 | 1080 | 25 Hz | | ||
| | WUXGA | 1920 | 1200 | 25 Hz | | ||
| | WXGA+ | 1440 | 900 | 25 Hz | | ||
| | XGA | 1024 | 768 | 60 Hz | | ||
|
|
||
| <Warning> | ||
| Higher resolutions may affect the responsiveness of [live view](/browsers/live-view) browser sessions. | ||
| </Warning> | ||
|
|
||
| ## Example configurations | ||
|
|
||
| <CodeGroup> | ||
|
|
||
| ```typescript Typescript/Javascript | ||
| // Full HD (1920x1080) at 25Hz - explicit refresh rate | ||
| const fullHD = await kernel.browsers.create({ | ||
| viewport: { | ||
| width: 1920, | ||
| height: 1080, | ||
| refresh_rate: 25 | ||
| } | ||
| }); | ||
|
|
||
| // Full HD (1920x1080) - auto-determined 25Hz | ||
| const fullHDAuto = await kernel.browsers.create({ | ||
| viewport: { | ||
| width: 1920, | ||
| height: 1080 | ||
| } | ||
| }); | ||
|
|
||
| // QHD (2560x1440) - auto-determined 10Hz | ||
| // Note: May affect live view responsiveness | ||
| const qhd = await kernel.browsers.create({ | ||
| viewport: { | ||
| width: 2560, | ||
| height: 1440 | ||
| } | ||
| }); | ||
|
|
||
| // XGA (1024x768) - auto-determined 60Hz (Default configuration) | ||
| const xga = await kernel.browsers.create({ | ||
| viewport: { | ||
| width: 1024, | ||
| height: 768 | ||
| } | ||
| }); | ||
|
|
||
| // WUXGA (1920x1200) at 25Hz - explicit refresh rate | ||
| const wuxga = await kernel.browsers.create({ | ||
| viewport: { | ||
| width: 1920, | ||
| height: 1200, | ||
| refresh_rate: 25 | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| ```python Python | ||
| # Full HD (1920x1080) at 25Hz - explicit refresh rate | ||
| full_hd = await client.browsers.create( | ||
| viewport={ | ||
| "width": 1920, | ||
| "height": 1080, | ||
| "refresh_rate": 25 | ||
| } | ||
| ) | ||
|
|
||
| # Full HD (1920x1080) - auto-determined 25Hz | ||
| full_hd_auto = await client.browsers.create( | ||
| viewport={ | ||
| "width": 1920, | ||
| "height": 1080 | ||
| } | ||
| ) | ||
|
|
||
| # QHD (2560x1440) - auto-determined 10Hz | ||
| # Note: May affect live view responsiveness | ||
| qhd = await client.browsers.create( | ||
| viewport={ | ||
| "width": 2560, | ||
| "height": 1440 | ||
| } | ||
| ) | ||
|
|
||
| # XGA (1024x768) - auto-determined 60Hz (Default configuration) | ||
| xga = await client.browsers.create( | ||
| viewport={ | ||
| "width": 1024, | ||
| "height": 768 | ||
| } | ||
| ) | ||
|
|
||
| # WUXGA (1920x1200) at 25Hz - explicit refresh rate | ||
| wuxga = await client.browsers.create( | ||
| viewport={ | ||
| "width": 1920, | ||
| "height": 1200, | ||
| "refresh_rate": 25 | ||
| } | ||
| ) | ||
| ``` | ||
|
|
||
| </CodeGroup> | ||
|
|
||
| ## Default viewport | ||
|
|
||
| If the `viewport` parameter is omitted when creating a browser, the default configuration is typically 1024x768 at 60Hz. | ||
|
|
||
| <CodeGroup> | ||
|
|
||
| ```typescript Typescript/Javascript | ||
| // Uses default viewport (1024x768@60Hz) | ||
| const defaultViewport = await kernel.browsers.create(); | ||
| ``` | ||
|
|
||
| ```python Python | ||
| # Uses default viewport (1024x768@60Hz) | ||
| default_viewport = await client.browsers.create() | ||
| ``` | ||
|
|
||
| </CodeGroup> | ||
|
|
||
| ## Viewport constraints | ||
|
|
||
| Only the specific viewport configurations listed in the [supported configurations table](#supported-viewport-configurations) above are supported: | ||
| - **2560x1440** (QHD) at 10 Hz | ||
| - **1920x1080** (Full HD) at 25 Hz | ||
| - **1920x1200** (WUXGA) at 25 Hz | ||
| - **1440x900** (WXGA+) at 25 Hz | ||
| - **1024x768** (XGA) at 60 Hz | ||
|
|
||
| When specifying a viewport: | ||
| - **Width** and **Height** are required and must match one of the supported configurations exactly | ||
| - **Refresh Rate** is optional - if omitted, it will be automatically determined from the width and height combination | ||
|
|
||
| <Warning> | ||
| The server will reject any viewport configuration that doesn't exactly match one of the supported combinations listed above. | ||
| </Warning> | ||
|
|
||
| ## Considerations | ||
|
|
||
| - The viewport configuration is set when the browser is created and applies to the initial browser window | ||
| - Higher resolutions (like 2560x1440) may impact the performance and responsiveness of live view sessions | ||
| - The viewport size affects how websites render, especially those with responsive designs | ||
| - Screenshots taken from the browser will match the configured viewport dimensions | ||
| - In [headless mode](/browsers/headless), the viewport configuration still applies for rendering and screenshots |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this directly above Browser Replays in the Pricing features list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done