-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters