#๐Ÿ”’ Am I using downloadsPath incorrectly in playwright?

11 messages ยท Page 1 of 1 (latest)

modern hill
#

The documentation says to use downloadsPath but when I try it like that it gives an unexpected argument. Instead I have it like this but I dont believe the downloads are actually going in the path

user_data_dir = r"C:\Users\WORKPC\AppData\Local\Google\Chrome\User Data"

# Define the directory path
downloads_path = './Videos/'

with sync_playwright() as p:
    # Launch a persistent context with user data directory
    browser = p.chromium.launch_persistent_context(
        user_data_dir,
        headless=False,
        downloads_path=downloads_path  # Specify the downloads directory
    )
    page = browser.new_page()```
untold canopyBOT
#

@modern hill

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

modern hill
# pastel flame Can you show us the error ?

with the downloads_path there is no error but with the downloadsPath like the docs say i get

Traceback (most recent call last):
  File "C:\Users\WORKPC\PycharmProjects\pythonProject\invideoGenerator.py", line 14, in <module>
    browser = p.chromium.launch_persistent_context(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BrowserType.launch_persistent_context() got an unexpected keyword argument 'downloadsPath'

Process finished with exit code 1```
pastel flame
#

Ah

#

I think you've read the javascript docs

#

The parameter in python is named downloads_path, and not downloadsPath

#

One is snake_case, the other is camelCase

pastel flame
untold canopyBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.