Skip to content

Commit

Permalink
setState API doc
Browse files Browse the repository at this point in the history
  • Loading branch information
flaurida committed Mar 9, 2020
1 parent 251aef1 commit 13c547c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/docs/api/components/qawolf/ArgumentSaveState.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import Argument from '../Argument';

function ArgumentSaveState() {
function ArgumentSaveState({ isSaved }) {
return (
<React.Fragment>
<Argument
Expand All @@ -20,7 +20,7 @@ function ArgumentSaveState() {
<Argument
description={
<React.Fragment>
The path where the state will be saved as{' '}
The path where the state {isSaved ? 'is' : 'will be'} saved as{' '}
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON">
JSON
</a>
Expand Down
33 changes: 33 additions & 0 deletions docs/docs/api/qawolf/set_state.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
id: set_state
sidebar_label: setState
title: qawolf.setState
---

import ArgumentSaveState from '../components/qawolf/ArgumentSaveState';
import ReturnVoid from '../components/qawolf/ReturnVoid';
import Syntax from '../components/Syntax';

<Syntax code="setState(page, savePath)" />

Set the state of a page (cookies, [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)) to the values saved as [JSON](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON) in the specified file.

See the [handle log in guide](TODOFIXLINK) to learn more about using `setState`.

### Arguments

<ArgumentSaveState isSaved />

### Returns

<ReturnVoid />

### Examples

Set the state of a page to the values saved in the `admin.json` file:

```js
const qawolf = require('qawolf');
// ...
await qawolf.setState(page, '../state/admin.json');
```
2 changes: 2 additions & 0 deletions docs/docs/api/table_of_contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ In addition to the APIs below, you have full access to the [Playwright API](http

[scroll](qawolf/scroll)

[setState](qawolf/set_state)

## class: BrowserContext

[class: BrowserContext](browser_context/class_browser_context)
Expand Down
1 change: 1 addition & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = {
'api/qawolf/repl',
'api/qawolf/save_state',
'api/qawolf/scroll',
'api/qawolf/set_state',
],
},
{
Expand Down

0 comments on commit 13c547c

Please sign in to comment.