From c3843130586aa835c610a4bf6fb2e09a9876cc39 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 5 Nov 2020 05:22:49 -0800 Subject: [PATCH] feat(fill): allow filling based on the label selector (#4342) This enables filling the input based on the connected label: ```html ``` ```js await page.fill('text=Name', 'Alice'); ``` --- docs/input.md | 14 ++++++++---- src/server/injected/injectedScript.ts | 33 ++++++++++++--------------- test/check.spec.ts | 17 ++++++++++++++ test/page-fill.spec.ts | 18 +++++++++++++++ 4 files changed, 59 insertions(+), 23 deletions(-) diff --git a/docs/input.md b/docs/input.md index cf79b4c0a4..4958178f51 100644 --- a/docs/input.md +++ b/docs/input.md @@ -2,7 +2,7 @@ - [Text input](#text-input) -- [Checkboxes](#checkboxes) +- [Checkboxes and radio buttons](#checkboxes-and-radio-buttons) - [Select options](#select-options) - [Mouse click](#mouse-click) - [Type characters](#type-characters) @@ -15,7 +15,7 @@ ## Text input -This is the easiest way to fill out the form fields. It focuses the element and triggers an `input` event with the entered text. It works for ``, ``); + await page.fill('text=Fill me', 'some value'); + expect(await page.$eval('textarea', textarea => textarea.value)).toBe('some value'); +}); + it('should throw on unsupported inputs', async ({page, server}) => { await page.goto(server.PREFIX + '/input/textarea.html'); for (const type of ['color', 'file']) {