Skip to content

Commit

Permalink
Scroll API doc
Browse files Browse the repository at this point in the history
  • Loading branch information
flaurida committed Mar 9, 2020
1 parent 65d6ab4 commit 251aef1
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
66 changes: 66 additions & 0 deletions docs/docs/api/components/qawolf/ArgumentScroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react';
import Argument from '../Argument';

function ArgumentScroll() {
return (
<React.Fragment>
<Argument
description={
<React.Fragment>
The{' '}
<a href="https://github.com/microsoft/playwright/blob/master/docs/api.md#class-page">
Playwright <code>Page</code>
</a>{' '}
instance.
</React.Fragment>
}
name="page"
type="Page"
/>
<Argument
description="Selector of the element to scroll."
name="selector"
type="string"
/>
<Argument description="Scroll options." name="options" type="Object" />
<Argument
description="Horizontal position to scroll element to in pixels."
indent
name="x"
type="number"
/>
<Argument
description="Vertical position to scroll element to in pixels."
indent
name="y"
type="number"
/>
<Argument
description={
<React.Fragment>
Maximum time in milliseconds to wait for element to reach specified
scroll position. <b>Default:</b> <code>30000</code>.
</React.Fragment>
}
indent
name="timeout"
optional
type="number"
/>
<Argument
description={
<React.Fragment>
When to consider navigation over before trying to scroll.{' '}
<b>Default:</b> <code>"load"</code>.
</React.Fragment>
}
indent
name="waitUntil"
optional
type='"commit" | "load" | "domcontentloaded" | "networkidle0" | "networkidle2"'
/>
</React.Fragment>
);
}

export default ArgumentScroll;
4 changes: 3 additions & 1 deletion docs/docs/api/qawolf/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import Syntax from '../components/Syntax';

<Syntax code="create([options={}])" />

Converts your browser actions to code. Call `create` in a code file to insert new code where it was called. See the [edit mode guide](TODOFIXLINK) to learn more about using `create`.
Convert your browser actions to code. Call `create` in a test or script file to insert new code where it was called.

See the [edit mode guide](TODOFIXLINK) to learn more about using `create`.

### Arguments

Expand Down
53 changes: 53 additions & 0 deletions docs/docs/api/qawolf/scroll.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
id: scroll
sidebar_label: scroll
title: qawolf.scroll
---

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

<Syntax code="scroll(page, selector, options)" />

Find and scroll an element on the specified [Playwright `Page`](https://github.com/microsoft/playwright/blob/master/docs/api.md#class-page) instance. Scroll until `element.scrollLeft` is equal to `options.x` and `element.scrollTop` is equal to `options.y`.

If the element is not found before timeout or the element cannot scroll **at all**, an error is thrown. If the element can scroll some, an error is not thrown.

### Arguments

<ArgumentScroll />

### Returns

<ReturnVoid />

### Examples

Scroll the element with the `id` of `"container"` vertically by 200 pixels:

```js
const qawolf = require('qawolf');
// ...
qawolf.scroll(page, '#container', { x: 0, y: 200 });
```

Scroll the element with the `id` of `"container"` horizontally by 100 pixels, timing out in 10 seconds if the element cannot scroll:

```js
const qawolf = require('qawolf');
// ...
qawolf.scroll(page, '#container', { x: 100, y: 0, timeoutMs: 10000 });
```

Scroll the element with the specified default selector vertically by 200 pixels. Consider navigation to be complete after the `DOMContentLoaded` event fires:

```js
const qawolf = require('qawolf');
// ...
qawolf.scroll(page, selectors['2_container_div'], {
x: 0,
y: 200,
waitUntil: 'domcontentloaded',
});
```
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 @@ -55,6 +55,8 @@ In addition to the APIs below, you have full access to the [Playwright API](http

[saveState](qawolf/save_state)

[scroll](qawolf/scroll)

## 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 @@ -45,6 +45,7 @@ module.exports = {
'api/qawolf/register',
'api/qawolf/repl',
'api/qawolf/save_state',
'api/qawolf/scroll',
],
},
{
Expand Down

0 comments on commit 251aef1

Please sign in to comment.