From 608873e9454cdd4e949b1de39208aaf3370c6ce3 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 2 Mar 2022 09:33:44 -0800 Subject: [PATCH] test: inputValue works for label selector (#12447) --- tests/page/locator-convenience.spec.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/page/locator-convenience.spec.ts b/tests/page/locator-convenience.spec.ts index 2cba820a3b..39986e6526 100644 --- a/tests/page/locator-convenience.spec.ts +++ b/tests/page/locator-convenience.spec.ts @@ -64,6 +64,29 @@ it('inputValue should work on label', async ({ page, server }) => { expect(await page.locator('label').inputValue()).toBe('foo'); }); +it('should get value of input with label', async ({ page }) => { + await page.setContent(``); + expect(await page.inputValue('text=Fill me')).toBe('some value'); + await expect(page.locator('text=Fill me')).toHaveValue('some value'); +}); + +it('should get value of input with span inside the label', async ({ page }) => { + await page.setContent(``); + expect(await page.inputValue('text=Fill me')).toBe('some value'); + await expect(page.locator('text=Fill me')).toHaveValue('some value'); +}); + +it('should get value of textarea with label', async ({ page }) => { + await page.setContent(``); + expect(await page.inputValue('text=Fill me')).toBe('hey'); + await expect(page.locator('text=Fill me')).toHaveValue('hey'); + + await page.fill('textarea', 'Look at this'); + expect(await page.inputValue('text=Fill me')).toBe('Look at this'); + await expect(page.locator('text=Fill me')).toHaveValue('Look at this'); +}); + + it('innerHTML should work', async ({ page, server }) => { await page.goto(`${server.PREFIX}/dom.html`); const locator = page.locator('#outer');