Skip to content

Commit 628e64b

Browse files
inancgumusAgnesTouletheitortsergent
committed
Fix some changes for Locator filtering
Co-authored-by: Agnès Toulet <[email protected]> Co-authored-by: Heitor Tashiro Sergent <[email protected]>
1 parent 7d38fd9 commit 628e64b

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

docs/sources/k6/next/javascript-api/k6-browser/frame/locator.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The method returns an element [Locator](https://grafana.com/docs/k6/<K6_VERSION>
1111

1212
| Parameter | Type | Default | Description |
1313
| ------------------- | ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14-
| selector | string | `''` | A selector to use when resolving DOM element. |
14+
| selector | string | `''` | A selector to use when resolving a DOM element. |
1515
| options | object | `null` | |
1616
| options.hasText | string or RegExp | `null` | Matches only elements that contain the specified text. String or regular expression. Optional. |
1717
| options.hasNotText | string or RegExp | `null` | Matches only elements that do not contain the specified text. String or regular expression. Optional. |
@@ -47,14 +47,18 @@ export const options = {
4747
export default async function () {
4848
const page = await browser.newPage();
4949

50-
await page.goto('https://quickpizza.grafana.com');
50+
try {
51+
await page.goto('https://quickpizza.grafana.com');
5152

52-
// Get the mainframe of the page
53-
const frame = page.mainFrame();
53+
// Get the mainframe of the page
54+
const frame = page.mainFrame();
5455

55-
// Create a locator with text filtering options
56-
const submitButton = frame.locator('button', { hasText: 'Pizza, Please!' });
57-
await submitButton.click();
56+
// Create a locator with text filtering options
57+
const submitButton = frame.locator('button', { hasText: 'Pizza, Please!' });
58+
await submitButton.click();
59+
} finally {
60+
await page.close();
61+
}
5862
}
5963
```
6064

docs/sources/k6/next/javascript-api/k6-browser/framelocator/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ weight: 09
66

77
# FrameLocator
88

9-
FrameLocator represents a way to find element(s) in an iframe. Frames can be nested, and this locator supports selecting a frame element and then working with it.
9+
FrameLocator represents a way to find element(s) in an `iframe`. Frames can be nested, and this locator supports selecting a frame element and then working with it.
1010

11-
A FrameLocator can be created with the [locator.contentFrame()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/) method.
11+
A FrameLocator can be created with the `locator.contentFrame()` method.
1212

1313
| Method | Description |
1414
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |

docs/sources/k6/next/javascript-api/k6-browser/framelocator/locator.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ description: 'Browser module: frameLocator.locator(selector[, options]) method'
55

66
# locator(selector[, options])
77

8-
The method returns an element [Locator](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/). Locators resolve to the element when the action takes place, which means locators can span over navigations where the underlying dom changes.
8+
The method returns an element's [Locator](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/). Locators resolve to the element when the action takes place, which means locators can span over navigations where the underlying DOM changes.
99

1010
<TableWithNestedRows>
1111

1212
| Parameter | Type | Default | Description |
1313
| ------------------- | ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14-
| selector | string | `''` | A selector to use when resolving DOM element. |
14+
| selector | string | `''` | A selector to use when resolving a DOM element. |
1515
| options | object | `null` | |
1616
| options.hasText | string or RegExp | `null` | Matches only elements that contain the specified text. String or regular expression. Optional. |
1717
| options.hasNotText | string or RegExp | `null` | Matches only elements that do not contain the specified text. String or regular expression. Optional. |
@@ -22,7 +22,7 @@ The method returns an element [Locator](https://grafana.com/docs/k6/<K6_VERSION>
2222

2323
| Type | Description |
2424
| -------------------------------------------------------------------------------------- | ------------------------------------------------ |
25-
| [Locator](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/) | The element `Locator` associated with the frame. |
25+
| [Locator](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/) | The element's `Locator` associated with the frame. |
2626

2727
### Example
2828

docs/sources/k6/next/javascript-api/k6-browser/locator/locator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ description: 'Browser module: locator.locator(selector[, options]) method'
55

66
# locator(selector[, options])
77

8-
Creates and returns a new locator chained/relative to the current locator. Locators resolve to the element when the action takes place, which means locators can span over navigations where the underlying dom changes.
8+
The method finds all elements matching the selector and creates a new [Locator](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/) that matches all of them. This method can be used to further refine the locator by chaining additional selectors.
99

1010
This allows you to define locators relative to a parent locator, enabling more precise element targeting by creating nested locators.
1111

1212
<TableWithNestedRows>
1313

1414
| Parameter | Type | Default | Description |
1515
| ------------------- | ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
16-
| selector | string | `''` | A selector to use when resolving DOM element. |
16+
| selector | string | `''` | A selector to use when resolving a DOM element. |
1717
| options | object | `null` | |
1818
| options.hasText | string or RegExp | `null` | Matches only elements that contain the specified text. String or regular expression. Optional. |
1919
| options.hasNotText | string or RegExp | `null` | Matches only elements that do not contain the specified text. String or regular expression. Optional. |

docs/sources/k6/next/javascript-api/k6-browser/page/locator.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The method returns an element [Locator](https://grafana.com/docs/k6/<K6_VERSION>
1111

1212
| Parameter | Type | Default | Description |
1313
| ------------------- | ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14-
| selector | string | `''` | A selector to use when resolving DOM element. |
14+
| selector | string | `''` | A selector to use when resolving a DOM element. |
1515
| options | object | `null` | |
1616
| options.hasText | string or RegExp | `null` | Matches only elements that contain the specified text. String or regular expression. Optional. |
1717
| options.hasNotText | string or RegExp | `null` | Matches only elements that do not contain the specified text. String or regular expression. Optional. |
@@ -47,11 +47,15 @@ export const options = {
4747
export default async function () {
4848
const page = await browser.newPage();
4949

50-
await page.goto('https://quickpizza.grafana.com');
50+
try {
51+
await page.goto('https://quickpizza.grafana.com');
5152

52-
// Create a locator with text filtering options
53-
const submitButton = page.locator('button', { hasText: 'Pizza, Please!' });
54-
await submitButton.click();
53+
// Create a locator with text filtering options
54+
const submitButton = page.locator('button', { hasText: 'Pizza, Please!' });
55+
await submitButton.click();
56+
} finally {
57+
await page.close();
58+
}
5559
}
5660
```
5761

0 commit comments

Comments
 (0)