0

I'm running the Selenium-grid standalone server on Ubuntu using this command

java -jar selenium-server-4.8.0.jar standalone --downloads-path /etc/selenoid/download

but when the driver downloads files they are being downloaded to the path of "/home/my_username/" which is where I'm running the server from the command line at. So this looks like the default download path, which is ignoring my --downloads-path argument.

My server does have an /etc/selenoid/download directory as well and the my_username:myusername owns that directory. So selenium Grid should have permissions to create/delete/edit files/folders within that directory.

I'm also setting the download.default_directory when setting the options of the driver.

options = webdriver.ChromeOptions()
options.add_argument('download.default_directory=/etc/selenoid/download')
options.add_experimental_option('prefs', {
                        "profile.default_content_setting_values.notifications": 2,
                        "download.default_directory": "/etc/selenoid/download",
                        "download.prompt_for_download": False,
                        "download.directory_upgrade": True,
                        "safebrowsing.enabled": False,
                        "plugins.always_open_pdf_externally": True,
                        "plugins.plugins_disabled": ["Chrome PDF Viewer"]
                        })

webdriver.Remote(command_executor=grid_uri, options=options)

I'm lost at the moment, when I run this on my local mac machine it works as expected, but not on my linux server.

Ryan Nygard
  • 200
  • 8
  • 1
    If the WebDriver test and Selenium Grid on the same host then you can see what download path has been phycially set by your `RemoteWebDriver` by breakpointing the test when a Chrome instance is created. In the resulting Chrome browser (being controlled by `RemoteWebDriver`) open 'Settings -> Downloads' and check the path. `--downloads-path` will only used by the GET `/session//se/file` endpoint to retrieve the downloaded file from the remote Node session. – mactwixs Feb 23 '23 at 12:24
  • This might also be useful: https://github.com/SeleniumHQ/selenium/issues/5292 – mactwixs Feb 23 '23 at 12:50
  • I think you need an absolute path there... and make sure the path is valid and that the browser has permission to write to it, or it will be ignored. – pcalkins Feb 23 '23 at 18:45

1 Answers1

0

I Discovered that when running Chrome headless it will not use the download.default_directory argument unless you run using the new headless mode, like so:

options.add_argument('--headless=new')

Here's the link to the stack overflow answer that solved the root of my problem: Downloading with chrome headless and selenium

Ryan Nygard
  • 200
  • 8