Skip to content

Commit 39451cd

Browse files
Add doc for select-text and set-clipboard commands
1 parent 20b8307 commit 39451cd

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

goml-script.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ Here's the command list:
235235
* [`scroll-element-to`](#scroll-element-to)
236236
* [`scroll-to`](#scroll-to)
237237
* [`set-attribute`](#set-attribute)
238+
* [`set-clipboard`](#set-clipboard)
238239
* [`set-css`](#set-css)
239240
* [`set-device-pixel-ratio`](#set-device-pixel-ratio)
240241
* [`set-document-property`](#set-document-property)
@@ -1759,6 +1760,33 @@ scroll-to: (10, 12)
17591760

17601761
This command scrolls the `<body>` element. If you want to scroll another element, use the [`scroll-element-to`][#scroll-element-to] command instead.
17611762

1763+
#### select-text
1764+
1765+
**select-text** command allows to select text. Nothing else. If you want to copy the selected text or something else, you'll another command.
1766+
1767+
It takes a tuple of two selectors as argument: the first one is where the text selection should start and the second one is where the selection should end. Example with this HTML code:
1768+
1769+
```html
1770+
<div>
1771+
<p id="a">hello</p>
1772+
<p id="b">I'm</p>
1773+
<p id="c">some</p>
1774+
<p id="d">html</p>
1775+
</div>
1776+
```
1777+
1778+
If we only want "I'm some", we use:
1779+
1780+
```
1781+
select-text: ("#b", "#c")
1782+
```
1783+
1784+
If we only want "some", we use:
1785+
1786+
```
1787+
select-text: ("#c", "#c")
1788+
```
1789+
17621790
#### set-attribute
17631791

17641792
**set-attribute** command allows to update an element's attribute. Example:
@@ -1775,6 +1803,16 @@ To remove an attribute, you can use the `null` ident:
17751803
set-attribute: ("a", {"href": null})
17761804
```
17771805

1806+
#### set-clipboard
1807+
1808+
**set-clipboard** command allows to set the content of the clipboard. It needs the `clipboard-write` permission. Example:
1809+
1810+
```
1811+
permissions: ["clipboard-write"]
1812+
set-clipboard: "hello"
1813+
set-clipboard: 112
1814+
```
1815+
17781816
#### set-css
17791817

17801818
**set-css** command allows to update an element's style. Example:

0 commit comments

Comments
 (0)