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:
3131
3232{{< code >}}
3333
34+ <!-- md-k6:skip -->
35+
3436``` javascript
3537import { browser } from ' k6/browser' ;
3638
@@ -72,6 +74,8 @@ Use exact matching for precise alt text:
7274
7375{{< code >}}
7476
77+ <!-- md-k6:skip -->
78+
7579``` javascript
7680import { browser } from ' k6/browser' ;
7781
@@ -113,6 +117,8 @@ Find images using pattern matching:
113117
114118{{< code >}}
115119
120+ <!-- md-k6:skip -->
121+
116122``` javascript
117123import { browser } from ' k6/browser' ;
118124
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ Fill form fields using their labels:
3131
3232{{< code >}}
3333
34+ <!-- md-k6:skip -->
35+
3436``` javascript
3537import { browser } from ' k6/browser' ;
3638
@@ -77,6 +79,8 @@ Handle various form control types in various label association patterns:
7779
7880{{< code >}}
7981
82+ <!-- md-k6:skip -->
83+
8084``` javascript
8185import { browser } from ' k6/browser' ;
8286
@@ -146,22 +150,40 @@ The `getByLabel()` method works with several HTML patterns for associating label
146150
147151** 1. Explicit association with ` for ` attribute:**
148152
153+ {{< code >}}
154+
155+ <!-- eslint-skip -->
156+
149157``` html
150158<label for =" username" >Username</label > <input type =" text" id =" username" name =" username" />
151159```
152160
161+ {{< /code >}}
162+
153163** 2. ARIA labeling:**
154164
165+ {{< code >}}
166+
167+ <!-- eslint-skip -->
168+
155169``` html
156170<span id =" username-label" >Username</span > <input type =" text" aria-labelledby =" username-label" />
157171```
158172
173+ {{< /code >}}
174+
159175** 3. ARIA label attribute:**
160176
177+ {{< code >}}
178+
179+ <!-- eslint-skip -->
180+
161181``` html
162182<input type =" text" aria-label =" Username" />
163183```
164184
185+ {{< /code >}}
186+
165187### Common use cases
166188
167189- ** 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:
2929
3030{{< code >}}
3131
32+ <!-- md-k6:skip -->
33+
3234``` javascript
3335import { browser } from ' k6/browser' ;
3436
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ Find and click a button by its role:
3939
4040{{< code >}}
4141
42+ <!-- md-k6:skip -->
43+
4244``` javascript
4345import { browser } from ' k6/browser' ;
4446
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ Locate and interact with elements using test IDs:
2929
3030{{< code >}}
3131
32+ <!-- md-k6:skip -->
33+
3234``` javascript
3335import { browser } from ' k6/browser' ;
3436
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ Find and click elements by their visible text:
2929
3030{{< code >}}
3131
32+ <!-- md-k6:skip -->
33+
3234``` javascript
3335import { browser } from ' k6/browser' ;
3436
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ Find and interact with elements by their title attribute:
2929
3030{{< code >}}
3131
32+ <!-- md-k6:skip -->
33+
3234``` javascript
3335import { browser } from ' k6/browser' ;
3436import { 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