Skip to content

Commit c601228

Browse files
author
rocketraccoon
committed
feat(testplane): docs for saveState and restoreState
1 parent 8502bda commit c601228

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# restoreState
2+
3+
## Overview {#overview}
4+
5+
Browser command that restore session state (cookies, local and session storages) from file or variable.
6+
7+
## Usage {#usage}
8+
9+
You can restore state from file (using `path` param) or from object (using `data` param)
10+
But if you provide both, file have a highest priority.
11+
Also you can provide `cookies`, `localStorage` and `sessionStorage` params for restore only that what you need.
12+
Data for restore state you can get from [saveState](../saveState) command.
13+
```typescript
14+
await browser.restoreState({
15+
path: './stateDump.json',
16+
data: stateDump,
17+
cookies: true,
18+
localStorage: true,
19+
sessionStorage: true,
20+
});
21+
```
22+
23+
## Usage Examples {#examples}
24+
25+
Restore state from file
26+
```typescript
27+
it("test", async ({ browser }) => {
28+
await browser.url("https://github.com/gemini-testing/testplane");
29+
30+
await browser.restoreState({
31+
path: './stateDump.json',
32+
});
33+
34+
// Reload page for see auth result.
35+
await browser.refresh();
36+
});
37+
```
38+
39+
## Related Commands {#related}
40+
41+
- [saveState](../saveState)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# saveState
2+
3+
## Overview {#overview}
4+
5+
Browser command that save session state (cookies, local and session storages).
6+
7+
## Usage {#usage}
8+
9+
Command return state dump from page, it will include cookie, localStorage nad sessionStorage.
10+
But using params you can disable some data.
11+
Also if you provide `path` param you can get dump in file.
12+
After save state you can use it in [restoreState](../restoreState) command.
13+
```typescript
14+
import type { SaveStateData } from "testplane";
15+
16+
const stateDump: SaveStateData = await browser.saveState({
17+
path: './stateDump.json',
18+
cookies: true,
19+
localStorage: true,
20+
sessionStorage: true,
21+
});
22+
```
23+
24+
## Usage Examples {#examples}
25+
26+
Save state in file
27+
```typescript
28+
it("test", async ({ browser }) => {
29+
await browser.url("https://github.com/gemini-testing/testplane");
30+
31+
await browser.saveState({
32+
path: './stateDump.json',
33+
});
34+
});
35+
```
36+
37+
## Related Commands {#related}
38+
39+
- [restoreState](../restoreState)

0 commit comments

Comments
 (0)