diff --git a/docs/src/api/class-elementhandle.md b/docs/src/api/class-elementhandle.md index 841ec7adc3..cc7e4021f0 100644 --- a/docs/src/api/class-elementhandle.md +++ b/docs/src/api/class-elementhandle.md @@ -516,7 +516,7 @@ Returns the `element.innerText`. ## async method: ElementHandle.inputValue - returns: <[string]> -Returns `input.value` for `` or ` + diff --git a/tests/page/elementhandle-convenience.spec.ts b/tests/page/elementhandle-convenience.spec.ts index 79ba9ce5a4..3ecd81be62 100644 --- a/tests/page/elementhandle-convenience.spec.ts +++ b/tests/page/elementhandle-convenience.spec.ts @@ -42,6 +42,9 @@ it('getAttribute should work', async ({ page, server }) => { it('inputValue should work', async ({ page, server }) => { await page.goto(`${server.PREFIX}/dom.html`); + await page.selectOption('#select', 'foo'); + expect(await page.inputValue('#select')).toBe('foo'); + await page.fill('#textarea', 'text value'); expect(await page.inputValue('#textarea')).toBe('text value'); @@ -50,9 +53,9 @@ it('inputValue should work', async ({ page, server }) => { const handle = await page.$('#input'); expect(await handle.inputValue()).toBe('input value'); - expect(await page.inputValue('#inner').catch(e => e.message)).toContain('Node is not an HTMLInputElement or HTMLTextAreaElement'); + expect(await page.inputValue('#inner').catch(e => e.message)).toContain('Node is not an HTMLInputElement or HTMLTextAreaElement or HTMLSelectElement'); const handle2 = await page.$('#inner'); - expect(await handle2.inputValue().catch(e => e.message)).toContain('Node is not an HTMLInputElement or HTMLTextAreaElement'); + expect(await handle2.inputValue().catch(e => e.message)).toContain('Node is not an HTMLInputElement or HTMLTextAreaElement or HTMLSelectElement'); }); it('innerHTML should work', async ({ page, server }) => { diff --git a/tests/page/locator-convenience.spec.ts b/tests/page/locator-convenience.spec.ts index db96de60b9..a8cd9ed5b0 100644 --- a/tests/page/locator-convenience.spec.ts +++ b/tests/page/locator-convenience.spec.ts @@ -42,6 +42,9 @@ it('getAttribute should work', async ({ page, server }) => { it('inputValue should work', async ({ page, server }) => { await page.goto(`${server.PREFIX}/dom.html`); + await page.selectOption('#select', 'foo'); + expect(await page.inputValue('#select')).toBe('foo'); + await page.fill('#textarea', 'text value'); expect(await page.inputValue('#textarea')).toBe('text value'); @@ -50,9 +53,9 @@ it('inputValue should work', async ({ page, server }) => { const locator = page.locator('#input'); expect(await locator.inputValue()).toBe('input value'); - expect(await page.inputValue('#inner').catch(e => e.message)).toContain('Node is not an HTMLInputElement or HTMLTextAreaElement'); + expect(await page.inputValue('#inner').catch(e => e.message)).toContain('Node is not an HTMLInputElement or HTMLTextAreaElement or HTMLSelectElement'); const locator2 = page.locator('#inner'); - expect(await locator2.inputValue().catch(e => e.message)).toContain('Node is not an HTMLInputElement or HTMLTextAreaElement'); + expect(await locator2.inputValue().catch(e => e.message)).toContain('Node is not an HTMLInputElement or HTMLTextAreaElement or HTMLSelectElement'); }); it('innerHTML should work', async ({ page, server }) => { diff --git a/types/types.d.ts b/types/types.d.ts index a575639c5a..5ce622f473 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -1890,7 +1890,7 @@ export interface Page { }): Promise; /** - * Returns `input.value` for the selected `` or `