playwright-python icon indicating copy to clipboard operation
playwright-python copied to clipboard

[BUG] 'browser.new_context' parameter 'locale' accepts any meaningless string

Open simon-liebehenschel opened this issue 3 years ago • 0 comments

async with async_playwright() as p:
      browser = await p.chromium.launch()
      context = await browser.new_context(locale="foO bAr Spam EGgs")  # <-- NO ERROR HERE

Expected behavior

Accept only adequate Languages Codes. Raise ValueError for any non-existing code.


Another problem is that nobody knows which strings Playwright accepts.

  • 'zh' ?
  • 'zh-CN' ?
  • 'zh_CN' ?

Ideally, a typing.Literal must be defined with a list of accepted languages' codes.

simon-liebehenschel avatar Apr 09 '22 19:04 simon-liebehenschel