diff --git a/release notes/v0.49.0.md b/release notes/v0.49.0.md index 76d3ce19432..4012283c8b0 100644 --- a/release notes/v0.49.0.md +++ b/release notes/v0.49.0.md @@ -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. + +
+ Expand to see an example of the new functionality. + +```javascript +import { check } from 'k6'; +import { browser } from 'k6/experimental/browser'; + +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(); +} +``` + +
### `` `#pr`