Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clear to the locator PR to the release notes #3524

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion release notes/v0.49.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,55 @@ k6 `v0.49.0` is here 🎉! This release includes:

## New features

_optional intro here_
### Add `clear` to the `locator` class [browser#1149](https://github.com/grafana/xk6-browser/pull/1149)

The new `clear` method on `locator` will clear text boxes and input fields. This is useful when navigating to a website where the text boxes and input fields already contain a value that needs to be cleared before filling it with a specific value.

<details>
<summary> Expand to see an example of the new functionality.</summary>

```javascript
import { check } from 'k6';
import { browser } from 'k6/x/browser';
ankur22 marked this conversation as resolved.
Show resolved Hide resolved

export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
}

export default async function() {
const context = browser.newContext();
const page = context.newPage();

await page.goto('https://test.k6.io/my_messages.php', { waitUntil: 'networkidle' });

// To mimic an input field with existing text.
page.locator('input[name="login"]').type('admin');

check(page, {
'not_empty': p => p.locator('input[name="login"]').inputValue() != '',
});

// Clear the text.
page.locator('input[name="login"]').clear();

check(page, {
'empty': p => p.locator('input[name="login"]').inputValue() == '',
});

page.close();
}
```

</details>

### `<big_feature_1>` `#pr`

Expand Down
Loading