Skip to content

Commit 2c577b1

Browse files
committed
Make viewport optional
1 parent d719d69 commit 2c577b1

File tree

1 file changed

+55
-23
lines changed

1 file changed

+55
-23
lines changed

browsers/viewport.mdx

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,57 @@ title: "Viewport Configuration"
33
description: "Configure browser viewport size and refresh rate for your automations"
44
---
55

6-
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.
6+
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.
77

88
## Setting viewport configuration
99

10-
You can configure the viewport when creating a browser by specifying the `viewport` parameter with `width`, `height`, and `refresh_rate`:
10+
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:
1111

1212
<CodeGroup>
1313

1414
```typescript Typescript/Javascript
15+
// Explicitly specify refresh rate
1516
const kernelBrowser = await kernel.browsers.create({
1617
viewport: {
1718
width: 1920,
1819
height: 1080,
1920
refresh_rate: 25
2021
}
2122
});
23+
24+
// Auto-determine refresh rate from dimensions (25Hz for 1920x1080)
25+
const kernelBrowserAuto = await kernel.browsers.create({
26+
viewport: {
27+
width: 1920,
28+
height: 1080
29+
}
30+
});
2231
```
2332

2433
```python Python
34+
# Explicitly specify refresh rate
2535
kernel_browser = client.browsers.create(
2636
viewport={
2737
"width": 1920,
2838
"height": 1080,
2939
"refresh_rate": 25
3040
}
3141
)
42+
43+
# Auto-determine refresh rate from dimensions (25Hz for 1920x1080)
44+
kernel_browser_auto = client.browsers.create(
45+
viewport={
46+
"width": 1920,
47+
"height": 1080
48+
}
49+
)
3250
```
3351

3452
</CodeGroup>
3553

3654
## Supported viewport configurations
3755

38-
Kernel supports specific viewport configurations. The server will reject unsupported combinations. The following resolutions are supported:
56+
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:
3957

4058
| Resolution | Width | Height | Refresh Rate |
4159
|------------|-------|--------|--------------|
@@ -54,7 +72,7 @@ Higher resolutions may affect the responsiveness of [live view](/browsers/live-v
5472
<CodeGroup>
5573

5674
```typescript Typescript/Javascript
57-
// Full HD (1920x1080) at 25Hz
75+
// Full HD (1920x1080) at 25Hz - explicit refresh rate
5876
const fullHD = await kernel.browsers.create({
5977
viewport: {
6078
width: 1920,
@@ -63,25 +81,32 @@ const fullHD = await kernel.browsers.create({
6381
}
6482
});
6583

66-
// QHD (2560x1440) at 10Hz - Note: May affect live view responsiveness
84+
// Full HD (1920x1080) - auto-determined 25Hz
85+
const fullHDAuto = await kernel.browsers.create({
86+
viewport: {
87+
width: 1920,
88+
height: 1080
89+
}
90+
});
91+
92+
// QHD (2560x1440) - auto-determined 10Hz
93+
// Note: May affect live view responsiveness
6794
const qhd = await kernel.browsers.create({
6895
viewport: {
6996
width: 2560,
70-
height: 1440,
71-
refresh_rate: 10
97+
height: 1440
7298
}
7399
});
74100

75-
// XGA (1024x768) at 60Hz - Default configuration
101+
// XGA (1024x768) - auto-determined 60Hz (Default configuration)
76102
const xga = await kernel.browsers.create({
77103
viewport: {
78104
width: 1024,
79-
height: 768,
80-
refresh_rate: 60
105+
height: 768
81106
}
82107
});
83108

84-
// WUXGA (1920x1200) at 25Hz
109+
// WUXGA (1920x1200) at 25Hz - explicit refresh rate
85110
const wuxga = await kernel.browsers.create({
86111
viewport: {
87112
width: 1920,
@@ -92,7 +117,7 @@ const wuxga = await kernel.browsers.create({
92117
```
93118

94119
```python Python
95-
# Full HD (1920x1080) at 25Hz
120+
# Full HD (1920x1080) at 25Hz - explicit refresh rate
96121
full_hd = await client.browsers.create(
97122
viewport={
98123
"width": 1920,
@@ -101,25 +126,32 @@ full_hd = await client.browsers.create(
101126
}
102127
)
103128

104-
# QHD (2560x1440) at 10Hz - Note: May affect live view responsiveness
129+
# Full HD (1920x1080) - auto-determined 25Hz
130+
full_hd_auto = await client.browsers.create(
131+
viewport={
132+
"width": 1920,
133+
"height": 1080
134+
}
135+
)
136+
137+
# QHD (2560x1440) - auto-determined 10Hz
138+
# Note: May affect live view responsiveness
105139
qhd = await client.browsers.create(
106140
viewport={
107141
"width": 2560,
108-
"height": 1440,
109-
"refresh_rate": 10
142+
"height": 1440
110143
}
111144
)
112145

113-
# XGA (1024x768) at 60Hz - Default configuration
146+
# XGA (1024x768) - auto-determined 60Hz (Default configuration)
114147
xga = await client.browsers.create(
115148
viewport={
116149
"width": 1024,
117-
"height": 768,
118-
"refresh_rate": 60
150+
"height": 768
119151
}
120152
)
121153

122-
# WUXGA (1920x1200) at 25Hz
154+
# WUXGA (1920x1200) at 25Hz - explicit refresh rate
123155
wuxga = await client.browsers.create(
124156
viewport={
125157
"width": 1920,
@@ -152,12 +184,12 @@ default_viewport = await client.browsers.create()
152184
## Viewport constraints
153185

154186
The viewport configuration has the following constraints:
155-
- **Width**: Minimum 320px, Maximum 7680px
156-
- **Height**: Minimum 240px, Maximum 4320px
157-
- **Refresh Rate**: Must match the supported configurations listed above
187+
- **Width** (required): Minimum 320px, Maximum 7680px
188+
- **Height** (required): Minimum 240px, Maximum 4320px
189+
- **Refresh Rate** (optional): If provided, must match the supported configurations listed above. If omitted, automatically determined from width and height.
158190

159191
<Note>
160-
While the API accepts width and height values within the min/max ranges, only the specific resolution and refresh rate combinations listed in the supported configurations table are actually supported. The server will reject any unsupported combinations.
192+
While the API accepts width and height values within the min/max ranges, only the specific resolution and refresh rate combinations listed in the supported configurations table are actually supported. When refresh_rate is omitted, it will be automatically determined if the width and height match a supported configuration exactly. The server will reject any unsupported combinations.
161193
</Note>
162194

163195
## Considerations

0 commit comments

Comments
 (0)