Add `opfs=` argument to `Save Storage State`
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 54/100
Línea de trabajo
Read Browser/keywords/playwright_state.py methods save_storage_state and _save_storage_state, then trace the request through protobuf/playwright.proto and node/playwright-wrapper/playwright-state.ts. Add the named opfs option and pass it to Playwright's storageState() call, update the Set Storage State docstring, and add OPFS cases to atest/test/01_Browser_Management/storage_state.robot for save, restore through both APIs, and saving without OPFS; skip or tag ephemeral WebKit contexts.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Use case
Save Storage State saves cookies and local storage, and with indexedDB=True and credentials=True also IndexedDB and virtual WebAuthn credentials (#5117). Some applications keep their data in the origin private file system (OPFS) instead: offline-first apps, apps that run SQLite in the browser (SQLite WASM persists to OPFS), and editors that store drafts as files. For those, the saved state misses the data the app needs, and the "set up once, reuse in every test" pattern does not work.
Playwright 1.63 added an opfs option to browserContext.storageState(). The state file then carries the OPFS entries of each origin, and both browser.newContext({ storageState }) and browserContext.setStorageState() restore them.
Proposed keyword / arguments
Save Storage State path=None * indexedDB=False credentials=False opfs=False
opfs: named-only, defaults toFalse. Also saves the origin private file system of every origin in the state.
*** Test Cases ***
Prepare Offline Data Once
New Context
New Page ${APP_URL}
Click id=download-for-offline
Get Text id=offline-status == Ready
Save Storage State ${CURDIR}/state/offline.json opfs=True
Use Offline Data
New Context storageState=${CURDIR}/state/offline.json
New Page ${APP_URL}
Get Text id=offline-status == Ready
New Context storageState= and Set Storage State need no new argument. They restore whatever the file contains.
Playwright API
browserContext.storageState({ opfs }), since 1.63 (opfs?: booleanappears intypes.d.tsof 1.63.0, not in 1.62.0). The docs note: "OPFS is currently not supported in ephemeral WebKit contexts."browserContext.setStorageState(storageState): since 1.63 its description says it clears "origin private file system entries" along with cookies, local storage, IndexedDB and credentials.browser.newContext({ storageState }).
Checked with Playwright 1.65.0 and Chromium: with opfs: true each origin in the state gets an opfs list of {path, type: "directory"} and {path, type: "file", base64} entries. A new context created with that state, and an existing context after setStorageState(), both read the file back. Without opfs: true no opfs key is written.
Implementation notes
All references are to upstream main (5e350998).
protobuf/playwright.proto:137-141Request.StorageState: addbool opfs = 4;. The rpc staysSaveStorageState(:713).node/playwright-wrapper/playwright-state.ts:1384-1388saveStorageState: passopfs: request.opfstocontext.c.storageState(), next toindexedDBandcredentials.Browser/keywords/playwright_state.py:2106-2112save_storage_state: add named-onlyopfs: bool = False; pass it through_save_storage_state(:2176-2185) intoRequest().StorageState(...). Docstring: one line in Arguments, plus the WebKit limitation.New Contextis an ephemeral context, so in WebKitopfs=Trueworks only afterNew Persistent Context.Browser/keywords/playwright_state.py:2196-2197set_storage_statedocstring: "Clears the cookies, local storage, IndexedDB and virtual WebAuthn credentials" should name OPFS too. Playwright clears it on everysetStorageState(), also when the file has noopfsentries: in the check above, restoring a state saved withoutopfsremoved the file the page had written. That is Playwright's behaviour since 1.63 and already happens with the current keyword, so the docstring fix stands on its own even withoutopfs=.Set Storage Statehas IndexedDB-specific handling (reload_pages,indexedDbOriginsatplaywright-state.ts:1392-1402, the open-connection probe at:1412-1432) because deleting an IndexedDB database waits for open connections. Playwright clears OPFS withremoveEntry(name, { recursive: true })and writes files withcreateWritable(). I have not found or tested a similar blocking case for OPFS. A file locked by aFileSystemSyncAccessHandlein a worker might make the clear fail instead of hang; worth one acceptance test before deciding whetherreload_pagesneeds to cover OPFS origins. Until then, no change there.- Tests:
atest/test/01_Browser_Management/storage_state.robothas the IndexedDB cases asEvaluate JavaScriptsnippets in its Variables (:9-14). Add matching OPFS write and read snippets and test: save withopfs=True, restore withNew Context storageState=, restore withSet Storage State, and save withoutopfsleaves noopfskey in the file. Skip or tag the WebKit case, since the suite runs in ephemeral contexts.
Backwards compatibility
Additive, named-only argument that defaults to False. State files written without it are unchanged. The docstring change to Set Storage State documents behaviour that is already there.
- Lenguaje dominante
- Python
- Estrellas
- 662
- Forks
- 149
- Merge medio
- 6 h 13 min
- PR fusionados (30 d)
- 121
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MarketSquare/robotframework-browser
-
priority: high
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
MarketSquare/robotframework-browser#5306 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
MarketSquare/robotframework-browser#5153 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
MarketSquare/robotframework-browser#5503 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 78/100
MarketSquare/robotframework-browser#5502 ·
Los mantenedores suelen responder en 1 día
-
Accept a list of credentials in `httpCredentials` of `New Context` and `New Persistent Context`Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
MarketSquare/robotframework-browser#5500 ·
Los mantenedores suelen responder en 1 día
Todos los issues de MarketSquare/robotframework-browser
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
igormcsouza/tether#278 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
aws-samples/sample-per-model-bedrock#803 ·
Los mantenedores suelen responder en 1 día
-
documentation p1
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
huggingface/accelerate#4511 ·
Los mantenedores suelen responder en 1 día
-
follow-up
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día