Skip to content

Commit

Permalink
Document Element.selection - grafana/k6#3519
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Jan 16, 2024
1 parent 44a5554 commit d175b88
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/sources/next/javascript-api/k6-html/element/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The Element object provides a similar API to the [DOM Element API](https://devel

| Method | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [selection](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-html/element/element-selection) | returns the selection that is matching the element |
| nodeName | The name of the element. |
| nodeType | The type of the element. |
| nodeValue | The element value. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: 'Element.selectionet()'
excerpt: 'Retrieve the Selection matching this element.'
---

# Element.selection()

Retrieve the Selection matching this element.

Mimics `$(element)`

### Returns

| Type | Description |
| ------- | ------------------------------------ |
| Selection | The Selection mathing this element. |

### Example

{{< code >}}

```javascript
import http from "k6/http";

export default () => {
let li = http.get("https://test.k6.io").html().find("li");
li.each(function(_, element) {
let container = element.selection().closest('ul.header-icons');
console.log("li.each", container.html())
});
}

```
{{< /code >}}

0 comments on commit d175b88

Please sign in to comment.