FileNotFoundError: [WinError 2]

from playwright.sync_api import Playwright, sync_playwright, expect
....
 page.get_by_label("Attachment:attachmentcloseFile Size < 50MB").click()
  page.wait_for_load_state("networkidle")
  page.get_by_label("Attachment:attachmentcloseFile Size < 50MB").set_input_files("C:\abc\update\abc.pdf")

How to fix it. Thanks!

Assuming the filename is not overtly incorrect, when using strings
containing backslashes (the windows path separator) as you are doing,
you should use “raw strings”, preceeding the string with an r:

 .set_input_files(r"C:\abc\update\abc.pdf")

Nonraw strings interpret various backslash escapes to indicate
particular characters, for example \n is a newline character.

The one which juumps out at me in your code is \a, which is the ASCII
BEL, code 7, which rings the terminal’s bell if printed to a terminal.

As such, your filename above has BEL characters where you expected the
two characters \a. Using a raw string avoids these escapes.

The other alternative is to use /, the forward slash, as the path
separator. As I understand it, this is also accepted in most Windows
uses:

 .set_input_files(r"C:/abc/update/abc.pdf")

Note that regular strings ("abc") and raw strings (r"abc") both just
result in a plain old Python str string object. They are just
different notations for expressing a string value in Python code.

Cheers,
Cameron Simpson cs@cskk.id.au

Reference:

And just in case - it doesn’t seem to apply here, but is important to understand for the future (if you ever want to use relative paths):