Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions docs/commands/browser/restoreState.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# restoreState

## Overview {#overview}

Browser command that restore session state (cookies, local and session storages) from file or variable.

<Admonition type="warning">
If you are using `webdriver` automation protocol you have to provide `webSocketUrl: true` in `desiredCapabilities` in config browser settings.
For `devtools` protocol don't need additional settings.
</Admonition>

## Usage {#usage}

You can restore state from file (using `path` param) or from object (using `data` param)
But if you provide both, file have a highest priority.
Also you can provide `cookies`, `localStorage` and `sessionStorage` params for restore only that what you need.
Data for restore state you can get from [saveState](../saveState) command.

```typescript
await browser.restoreState({
path: './stateDump.json',
data: stateDump,
cookies: true,
localStorage: true,
sessionStorage: true,
});
```

## Usage Examples {#examples}

Restore state from file
```typescript
it("test", async ({ browser }) => {
await browser.url("https://github.com/gemini-testing/testplane");

await browser.restoreState({
path: './stateDump.json',
});

// Reload page for see auth result.
await browser.refresh();
});
```

## Related Commands {#related}

- [saveState](../saveState)
47 changes: 47 additions & 0 deletions docs/commands/browser/saveState.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Admonition from "@theme/Admonition";

# saveState

## Overview {#overview}

Browser command that save session state (cookies, local and session storages).

<Admonition type="warning">
If you are using `webdriver` automation protocol you have to provide `webSocketUrl: true` in `desiredCapabilities` in config browser settings.
For `devtools` protocol don't need additional settings.
</Admonition>

## Usage {#usage}

Command return state dump from page, it will include cookie, localStorage and sessionStorage.
Copy link
Member

Choose a reason for hiding this comment

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

Command returns

It will include cookies

etc. I think it would be good to let some LLM scan this for typos and improve working

But using params you can disable some data.
Also if you provide `path` param you can get dump in file.
After save state you can use it in [restoreState](../restoreState) command.

```typescript
import type { SaveStateData } from "testplane";

const stateDump: SaveStateData = await browser.saveState({
path: './stateDump.json',
cookies: true,
localStorage: true,
sessionStorage: true,
});
```

## Usage Examples {#examples}

Save state in file
```typescript
it("test", async ({ browser }) => {
await browser.url("https://github.com/gemini-testing/testplane");

await browser.saveState({
path: './stateDump.json',
});
});
```

## Related Commands {#related}

- [restoreState](../restoreState)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# restoreState

## Обзор {#overview}

Команда для восстановления данных (cookies, local and session storages) из файла или объекта.

<Admonition type="warning">
Если вы используете `webdriver` automation protocol вы должны установить `webSocketUrl: true` в `desiredCapabilities` для браузера в конфиге.
Для `devtools` protocol не нужно дополнительных настроек.
</Admonition>

## Использование {#usage}

Вы можете восстановить данные из файла (используя параметр `path`) или из объекта (используя параметр`data`)
Copy link
Member

Choose a reason for hiding this comment

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

A lot of typos here e.g. "нуд=жные" and I'd use more structured language here. Again, I'd just use LLM to improve spelling and wording here

Но если вы укажете оба параметра то данные восстановятся из файла.
Так же вы можете указать параметры `cookies`, `localStorage` и `sessionStorage` что бы восстановить только нуд=жные данные.
Данные для восстановления вы моежете получить из команды [saveState](../saveState).

```typescript
await browser.restoreState({
path: './stateDump.json',
data: stateDump,
cookies: true,
localStorage: true,
sessionStorage: true,
});
```

## Примеры использования {#examples}

Восстановление данных из файла.
```typescript
it("test", async ({ browser }) => {
await browser.url("https://github.com/gemini-testing/testplane");

await browser.restoreState({
path: './stateDump.json',
});

// Reload page for see auth result.
await browser.refresh();
});
```

## Связанные команды {#related}

- [saveState](../saveState)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Admonition from "@theme/Admonition";

# saveState

## Обзор {#overview}

Команда для сохранения состояния страницы (cookies, local и session storages).

<Admonition type="warning">
Если вы используете `webdriver` automation protocol вы должны установить `webSocketUrl: true` в `desiredCapabilities` для браузера в конфиге.
Для `devtools` protocol не нужно дополнительных настроек.
</Admonition>

## Использование {#usage}

Команда вернёт объект включающий cookie, localStorage и sessionStorage.
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be nice to have "Command Parameters" table like we do on other pages, e.g. https://testplane.io/docs/v8/commands/browser/setMeta/

Используя параметры вы можете выключить сохранение отдельных данных.
Так же вы можете указать параметр `path` и получить файл с данными.
После сохранения вы можете использовать результат в команде [restoreState](../restoreState).

```typescript
import type { SaveStateData } from "testplane";

const stateDump: SaveStateData = await browser.saveState({
path: './stateDump.json',
cookies: true,
localStorage: true,
sessionStorage: true,
});
```

## Примеры использования {#examples}

Сохранение данных в файл.
```typescript
it("test", async ({ browser }) => {
await browser.url("https://github.com/gemini-testing/testplane");

await browser.saveState({
path: './stateDump.json',
});
});
```

## Связанные команды {#related}

- [restoreState](../restoreState)
Loading