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
* initial push
* remove comment
* add code snippets for uploading files
* improvements pass
* fix alignment
* docs fix
* update helper function
* Move info note to Playwright section
Moved beginning playwright note to info section
* Remove duplicate language
removed duplicate language from playwright section
* Update formatting
Update formatting + remove config addition step in code snippet for stagehand v3
* Cleaned up a few items
- Moved playwright specific callout to the end of the code snippets in Playwright section
- Added formatting changes for typescript code snippets
---------
description: "Downloads, uploads, and manipulating the browser's filesystem"
4
4
---
5
5
6
-
Kernel browsers run in fully sandboxed environments with a writable filesystem that you control. Anything your automation downloads during a session is saved inside this filesystem and can be retrieved directly while the session is running.
7
-
8
6
## Downloads
9
7
8
+
Kernel browsers run in fully sandboxed environments with writable filesystems. When your automation downloads a file, it's saved inside the browser's filesystem and can be retrieved using Kernel's File I/O APIs.
9
+
10
+
11
+
### Playwright
12
+
10
13
Playwright performs downloads via the browser itself, so there are a few steps:
11
14
12
15
- Create a browser session
13
-
- Configure where the browser saves downloads
16
+
- Configure where the browser saves downloads using CDP
14
17
- Perform the download
15
18
- Retrieve the file from the browser's filesystem
16
19
17
20
<Info>
18
-
The CDP `downloadProgress` event signals when the browser finishes writing a file, but there may be a brief delay before the file becomes available through Kernel's File I/O APIs. This is especially true for larger downloads. We recommend polling `listFiles` to confirm the file exists before attempting to read it.
21
+
The CDP `downloadProgress` event signals when the browser finishes writing a
22
+
file, but there may be a brief delay before the file becomes available through
23
+
Kernel's File I/O APIs. This is especially true for larger downloads. We
24
+
recommend polling `listFiles` to confirm the file exists before attempting to
25
+
read it.
19
26
</Info>
20
27
21
28
<CodeGroup>
@@ -126,7 +133,8 @@ async function main() {
126
133
}
127
134
128
135
main();
129
-
```
136
+
137
+
````
130
138
131
139
```python Python
132
140
import asyncio
@@ -221,29 +229,268 @@ async def main():
221
229
222
230
if __name__ == "__main__":
223
231
asyncio.run(main())
224
-
```
232
+
````
233
+
225
234
</CodeGroup>
226
235
227
-
We recommend using the [list files](/api-reference/browsers/list-files-in-a-directory) API to poll for file availability before calling [read file](/api-reference/browsers/read-file-contents), as shown in the examples above. This approach ensures reliable downloads, especially for larger files. You can also use `listFiles` to enumerate and save all downloads at the end of a session.
236
+
<Info>We recommend using the [list files](/api-reference/browsers/list-files-in-a-directory) API to poll for file availability before calling [read file](/api-reference/browsers/read-file-contents), as shown in the examples above. This approach ensures reliable downloads, especially for larger files. You can also use `listFiles` to enumerate and save all downloads at the end of a session.</Info>
237
+
238
+
### Stagehand v3
239
+
240
+
When using Stagehand with Kernel browsers, you need to configure the download behavior in the `localBrowserLaunchOptions`:
241
+
242
+
```typescript
243
+
const stagehand =newStagehand({
244
+
env: "LOCAL",
245
+
verbose: 1,
246
+
localBrowserLaunchOptions: {
247
+
cdpUrl: kernelBrowser.cdp_ws_url,
248
+
downloadsPath: DOWNLOAD_DIR, // Specify where downloads should be saved
0 commit comments