File tree Expand file tree Collapse file tree 7 files changed +38
-0
lines changed
docs/sources/k6/next/javascript-api/k6-browser/page Expand file tree Collapse file tree 7 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ Find and click an image by its alt text:
31
31
32
32
{{< code >}}
33
33
34
+ <!-- md-k6:skip -->
35
+
34
36
``` javascript
35
37
import { browser } from ' k6/browser' ;
36
38
@@ -72,6 +74,8 @@ Use exact matching for precise alt text:
72
74
73
75
{{< code >}}
74
76
77
+ <!-- md-k6:skip -->
78
+
75
79
``` javascript
76
80
import { browser } from ' k6/browser' ;
77
81
@@ -113,6 +117,8 @@ Find images using pattern matching:
113
117
114
118
{{< code >}}
115
119
120
+ <!-- md-k6:skip -->
121
+
116
122
``` javascript
117
123
import { browser } from ' k6/browser' ;
118
124
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ Fill form fields using their labels:
31
31
32
32
{{< code >}}
33
33
34
+ <!-- md-k6:skip -->
35
+
34
36
``` javascript
35
37
import { browser } from ' k6/browser' ;
36
38
@@ -77,6 +79,8 @@ Handle various form control types in various label association patterns:
77
79
78
80
{{< code >}}
79
81
82
+ <!-- md-k6:skip -->
83
+
80
84
``` javascript
81
85
import { browser } from ' k6/browser' ;
82
86
@@ -146,22 +150,40 @@ The `getByLabel()` method works with several HTML patterns for associating label
146
150
147
151
** 1. Explicit association with ` for ` attribute:**
148
152
153
+ {{< code >}}
154
+
155
+ <!-- eslint-skip -->
156
+
149
157
``` html
150
158
<label for =" username" >Username</label > <input type =" text" id =" username" name =" username" />
151
159
```
152
160
161
+ {{< /code >}}
162
+
153
163
** 2. ARIA labeling:**
154
164
165
+ {{< code >}}
166
+
167
+ <!-- eslint-skip -->
168
+
155
169
``` html
156
170
<span id =" username-label" >Username</span > <input type =" text" aria-labelledby =" username-label" />
157
171
```
158
172
173
+ {{< /code >}}
174
+
159
175
** 3. ARIA label attribute:**
160
176
177
+ {{< code >}}
178
+
179
+ <!-- eslint-skip -->
180
+
161
181
``` html
162
182
<input type =" text" aria-label =" Username" />
163
183
```
164
184
185
+ {{< /code >}}
186
+
165
187
### Common use cases
166
188
167
189
- ** Form testing** : Login forms, registration forms, contact forms
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ Find and fill inputs by their placeholder text:
29
29
30
30
{{< code >}}
31
31
32
+ <!-- md-k6:skip -->
33
+
32
34
``` javascript
33
35
import { browser } from ' k6/browser' ;
34
36
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ Find and click a button by its role:
39
39
40
40
{{< code >}}
41
41
42
+ <!-- md-k6:skip -->
43
+
42
44
``` javascript
43
45
import { browser } from ' k6/browser' ;
44
46
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ Locate and interact with elements using test IDs:
29
29
30
30
{{< code >}}
31
31
32
+ <!-- md-k6:skip -->
33
+
32
34
``` javascript
33
35
import { browser } from ' k6/browser' ;
34
36
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ Find and click elements by their visible text:
29
29
30
30
{{< code >}}
31
31
32
+ <!-- md-k6:skip -->
33
+
32
34
``` javascript
33
35
import { browser } from ' k6/browser' ;
34
36
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ Find and interact with elements by their title attribute:
29
29
30
30
{{< code >}}
31
31
32
+ <!-- md-k6:skip -->
33
+
32
34
``` javascript
33
35
import { browser } from ' k6/browser' ;
34
36
import { expect } from ' https://jslib.k6.io/k6-testing/0.5.0/index.js' ;
You can’t perform that action at this time.
0 commit comments