-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
area: browserbrowser: playwrightrelated to Playwright compatibilityrelated to Playwright compatibilityfeature
Description
Feature Description
With a getByPlaceholder
method, k6 Browser scripts can target input
s or textarea
s by their placeholder attribute: e.g., page.getByPlaceholder('Search…')
. This is particularly useful for quick form tests where the placeholder uniquely identifies a field. The implementation would locate all input
and textarea
elements with a matching placeholder
, respecting options for matcher type (exact, regex, etc.). This addition reduces the need for ad-hoc CSS selectors and mirrors best practices in modern test automation.
Playwright docs: https://playwright.dev/docs/api/class-page#page-get-by-placeholder
Note: this is only to be implemented on page
.
This should work after the implementation work:
await page.setContent(`
<html><body>
<input placeholder="Search…" />
</body></html>
`);
const searchInput = page.getByPlaceholder('Search…');
await searchInput.fill('playwright');
Suggested Solution (optional)
No response
Already existing or connected issues / PRs (optional)
Metadata
Metadata
Assignees
Labels
area: browserbrowser: playwrightrelated to Playwright compatibilityrelated to Playwright compatibilityfeature