From ee3c483fc3837bfb2892f406a32d1ef7c4643306 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Mon, 8 Jan 2024 16:43:19 +0000 Subject: [PATCH 1/2] Add clear to locator PR in release notes --- release notes/v0.49.0.md | 50 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/release notes/v0.49.0.md b/release notes/v0.49.0.md index 76d3ce19432..c92048d83b7 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/x/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` From cf3b52e0c9ab3e287ef2aad3a3add29e3c987473 Mon Sep 17 00:00:00 2001 From: Ankur Date: Tue, 9 Jan 2024 11:45:33 +0000 Subject: [PATCH 2/2] Use experimental import Co-authored-by: ka3de --- release notes/v0.49.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release notes/v0.49.0.md b/release notes/v0.49.0.md index c92048d83b7..4012283c8b0 100644 --- a/release notes/v0.49.0.md +++ b/release notes/v0.49.0.md @@ -24,7 +24,7 @@ The new `clear` method on `locator` will clear text boxes and input fields. This ```javascript import { check } from 'k6'; -import { browser } from 'k6/x/browser'; +import { browser } from 'k6/experimental/browser'; export const options = { scenarios: {