Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix: color input value is case-insensitive (#38580)

Yury Semikhatsky2cbab7eafaa8
diff --git a/packages/injected/src/injectedScript.ts b/packages/injected/src/injectedScript.ts
index 9c56273762..b25b6ccff8 100644
--- a/packages/injected/src/injectedScript.ts
+++ b/packages/injected/src/injectedScript.ts
@@ -836,6 +836,8 @@ export class InjectedScript {
if (isNaN(Number(value)))
throw this.createStacklessError('Cannot type text into input[type=number]');
}
+ if (type === 'color')
+ value = value.toLowerCase();
if (kInputTypesToSetValue.has(type)) {
value = value.trim();
input.focus();
diff --git a/tests/page/page-fill.spec.ts b/tests/page/page-fill.spec.ts
index cb37f3e6e1..51a5730175 100644
--- a/tests/page/page-fill.spec.ts
+++ b/tests/page/page-fill.spec.ts
@@ -73,6 +73,12 @@ it('should fill color input', async ({ page }) => {
expect(await page.$eval('input', input => input.value)).toBe('#aaaaaa');
});
+it('should fill color input case insensitive', async ({ page }) => {
+ await page.setContent('<input type=color value="#e66465">');
+ await page.fill('input', '#AbCd00');
+ expect(await page.$eval('input', input => input.value)).toBe('#abcd00');
+});
+
it('should throw on incorrect color value', async ({ page, browserName, isWindows }) => {
it.skip(browserName === 'webkit' && isWindows, 'WebKit win does not support color inputs');
await page.setContent('<input type=color value="#e66465">');