playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Bug]: Test browser native inputs such as date input in different languages

Open mello-r opened this issue 1 year ago • 2 comments

Version

1.48.0

Steps to reproduce

Reproduction

  1. Clone repo at https://github.com/mello-r/playwright-accept-language-bug
  2. pnpm install
  3. pnpm test:ui
  4. Input date has the English format and not the German as configured in playwright.config.ts

Expected behavior

I expect it will be possible to emulate a different language on the Playwright browser, to have a different format for browser native inputs such as date input.

Here how it looks in locale Firefox:

Image

Actual behavior

I could not find a way to get the Playwright browser to emulate a different language to display the native input date in a different format.

Here how it looks in Playwright:

Image

Additional context

At first, I wrote a comment on this issue in #18609, but mxschmitt told me that this was a different problem and should be a separate issue.

Environment

System: OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa) CPU: (16) x64 AMD Ryzen 7 5700U with Radeon Graphics Memory: 15.61 GB / 18.95 GB Container: Yes Binaries: Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node Yarn: 1.22.22 - ~/.nvm/versions/node/v20.11.1/bin/yarn npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm pnpm: 9.12.2 - /usr/bin/pnpm IDEs: VSCode: 1.94.1 - /mnt/c/Program Files/Microsoft VS Code/bin/code Languages: Bash: 5.0.17 - /usr/bin/bash npmPackages: @playwright/test: ^1.48.0 => 1.48.0

mello-r avatar Oct 17 '24 08:10 mello-r

We have the same issue. I have a MacBook with English locale system, and my co-worker, similar MacBook with German locale system. For me, the date input is dd.mm.yyyy - and "type" 26112025 or 26.11.2025 works For my co-worker, the date input is tt.mm.jjjj and 'type' 26112025 or 26.11.2025 doesn't work. Playwright messes up the value

slavko-hillcrown avatar Nov 25 '25 09:11 slavko-hillcrown

FYI HTML5 date inputs ALWAYS expect ISO format (YYYY-MM-DD) internally, regardless of how they display to the user. Use fill() for HTML5 date inputs.

const dateInput = page.locator('input[name="date"]');
await dateInput.fill('YYYY-MM-DD'); // ISO format: YYYY-MM-DD

slavko-hillcrown avatar Nov 25 '25 14:11 slavko-hillcrown