File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
docs/sources/next/javascript-api/k6-html/element Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ The Element object provides a similar API to the [DOM Element API](https://devel
16
16
17
17
| Method | Description |
18
18
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
19
+ | [ selection] ( https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-html/element/element-selection ) | The selection matching the element. |
19
20
| nodeName | The name of the element. |
20
21
| nodeType | The type of the element. |
21
22
| nodeValue | The element value. |
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : ' Element.selection()'
3
+ description : ' Retrieve the Selection matching this element.'
4
+ ---
5
+
6
+ # Element.selection()
7
+
8
+ Retrieve the Selection matching this element.
9
+
10
+ Mimics ` $(element) ` .
11
+
12
+ ### Returns
13
+
14
+ | Type | Description |
15
+ | ------- | ------------------------------------ |
16
+ | Selection | The Selection matching this element. |
17
+
18
+ ### Example
19
+
20
+ {{< code >}}
21
+
22
+ ``` javascript
23
+ import http from " k6/http" ;
24
+
25
+ export default () => {
26
+ let li = http .get (" https://test.k6.io" ).html ().find (" li" );
27
+ li .each (function (_ , element ) {
28
+ let container = element .selection ().closest (' ul.header-icons' );
29
+ console .log (" li.each" , container .html ())
30
+ });
31
+ }
32
+
33
+ ```
34
+ {{< /code >}}
You can’t perform that action at this time.
0 commit comments