Skip to content

Add Set Storage State keyword and indexedDB=/credentials= arguments on Save Storage State #5117 - #5149

Open
Snooz82 wants to merge 4 commits into
mainfrom
topic/storageState
Open

Add Set Storage State keyword and indexedDB=/credentials= arguments on Save Storage State #5117#5149
Snooz82 wants to merge 4 commits into
mainfrom
topic/storageState

Conversation

@Snooz82

@Snooz82 Snooz82 commented Aug 15, 2026

Copy link
Copy Markdown
Member

No description provided.

Copilot AI balanced review requested due to automatic review settings August 15, 2026 05:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements issue #5117 by expanding storage-state capture and enabling restoration into active contexts.

Changes:

  • Adds Set Storage State with timeout handling.
  • Supports custom paths, IndexedDB, and WebAuthn credentials.
  • Adds acceptance tests for storage-state scenarios.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
protobuf/playwright.proto Extends storage-state RPC contracts.
package-lock.json Refreshes dependency metadata.
node/playwright-wrapper/playwright-state.ts Implements save/set operations.
node/playwright-wrapper/grpc-service.ts Exposes the new gRPC operation.
Browser/keywords/playwright_state.py Adds and documents keyword APIs.
atest/test/01_Browser_Management/storage_state.robot Adds storage-state acceptance coverage.
Suppressed comments (1)

Browser/keywords/playwright_state.py:1798

  • The file is validated relative to the Python process, but this relative string is then opened by the Node wrapper from Browser/wrapper (Browser/playwright.py:280). Thus a documented call such as Set Storage State auth.json can pass is_file() and still fail in Playwright. Send an absolute path over gRPC.
                    path=str(path), timeout=int(self.get_timeout(timeout))

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread Browser/keywords/playwright_state.py Outdated
Comment on lines +1159 to +1165
try {
await Promise.race([
context.c.setStorageState(stateFile),
new Promise((_, reject) => {
timer = setTimeout(() => reject(new Error(timeoutMessage)), timeout);
}),
]);
Comment on lines +1160 to +1164
await Promise.race([
context.c.setStorageState(stateFile),
new Promise((_, reject) => {
timer = setTimeout(() => reject(new Error(timeoutMessage)), timeout);
}),
Snooz82 and others added 4 commits August 15, 2026 10:27
Review fixes for #5117:

- Resolve the path of Save Storage State and Set Storage State to an
  absolute one before sending it over grpc. The node wrapper runs with
  Browser/wrapper as its working directory, so a relative path was
  created in one directory and written in another, and the returned
  path pointed nowhere. Covered by a new acceptance test.
- Skip the Set Storage State timeout when it resolves to zero, which
  conventionally means no timeout.
- Do not leave the raced setStorageState promise unhandled, and say in
  the timeout message that the state can still be applied later, so the
  context should no longer be used.

Restore package-lock.json to the version on main. It had lost its
@emnapi entries, which broke npm ci and with it every CI job.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01SuiwgM8Rt9kd6K7TBtFMDz
The acceptance test that is disabled until playwright#42258 is fixed
called Skip without declaring it in its documentation. robotstatuschecker
derives the expected status from the documentation and defaults to PASS,
so it turned the skip into a failure and every job running the acceptance
tests ended with rc=1, even though Robot Framework itself reported no
failures.

New Context validated its storageState argument against the Robot
Framework working directory but sent the path on unresolved, while the
node wrapper runs with Browser/wrapper as its working directory. A
relative path therefore passed validation and then failed in the node
process with a raw ENOENT. Resolve it like Save Storage State and Set
Storage State already do, and extend the relative path test to cover
all three keywords.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01SuiwgM8Rt9kd6K7TBtFMDz
The suite failed on Windows with four tests, all of them assertions that
assumed forward slashes.

Save Storage State returns the resolved path, which uses the native
separator, while the expected values were built from Robot Framework
variables with forward slashes. Normalize the expected values before
comparing them.

The two invalid path tests matched the full error message, which now
contains a platform native separator because storageState and path are
Path arguments rather than strings. Match the separator with the glob
wildcard the expected error already supports.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01SuiwgM8Rt9kd6K7TBtFMDz
@Snooz82
Snooz82 force-pushed the topic/storageState branch from 2186256 to 48ff172 Compare August 15, 2026 08:54
@Snooz82 Snooz82 changed the title Implemented #5117 Add Set Storage State keyword and indexedDB=/credentials= arguments on Save Storage State #5117 Aug 15, 2026
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

Successfully merging this pull request may close these issues.

2 participants