Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capabilities' default_directory ignored in Chrome #5292

Closed
seangerhardt-wf opened this issue Jan 5, 2018 · 6 comments
Closed

Capabilities' default_directory ignored in Chrome #5292

seangerhardt-wf opened this issue Jan 5, 2018 · 6 comments

Comments

@seangerhardt-wf
Copy link

Meta

OS: Linux

Selenium Version: 3.8.1

Browser: Chrome

Browser Version: stable 62.0.3202.94

Expected Behavior

Downloads go to specified directory in capabilities' chrome prefs, which worked fine in Selenium v3.7.1 with Chromedriver: 2.33.506092

Actual Behavior

Downloads are going to file:///home/seluser/Downloads/, ignoring the capabilities' directory provided

Steps to reproduce

  1. Use Selenium Version: 3.8.1

  2. Use dart webdriver with following capabilities, and trigger a download in chrome

    Map capabilities = {
      'platform': 'LINUX',
      'browserName': 'chrome',
      'chromeOptions': {
        'args': ['window-size=1280,600', 'disable-infobars', 'enable-precise-memory-info'],
        'prefs': {
          'download': {'default_directory': '/shared/exports/', 'prompt_for_download': 'false'}
        }
      }
    }
  driver = await io.createDriver(desired: capabilities, uri: seleniumUri);

The version of Dart: Dart VM version: 1.24.2 (Thu Jun 22 15:42:21 2017) on "linux_x64"
The operating system: linux_x64
The version of the dart webdriver package: 1.2.3
The version of chromedriver: Chromedriver: 2.33.506092

@swifty-team
Copy link

+1

I have the same issue.
it works for my only in Selenium.WebDriver nuget (c#) version 3.3.0 (with chrome driver 2.27, chrome 54)

@kendalsickels-wf
Copy link

Digging into this more, looks like in a selenium grid setup chromeOptions are not being matched with goog:chromeOptions. Below is the chromedriver logs from a failure:

[1526270304.899][INFO]: COMMAND InitSession {
   "capabilities": {
      "desiredCapabilities": {
         "browserName": "chrome",
         "chromeOptions": {
            "args": [ "window-size=1440,900", "disable-infobars", "enable-precise-memory-info" ],
            "extensions": [ "Q3IyNAIAAAAmAQAAAAEAADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL+fiAlrZV+t
1lIyYR5aqiRRFdH0min2GSjrfwLCQG4tkwXa5Ml4GZRyDG8ymEcu1Xb0/sSYCZ79yzsrbBJsnLJzId/VUr
bdmqy79VbbaXqUlbGDxzf3e7OLjDmBAn23DKXg7..." ],
            "prefs": {
               "download.default_directory": "/home/seluser/exports",
               "download.prompt_for_download": false
            }
         },
         "extendedDebugging": true,
         "goog:chromeOptions": {

         },
         "platform": "LINUX",
         "seleniumProtocol": "WebDriver",
         "zal:name": "Doc: table_test.dart - Rich Text - Undo and Redo With Rich Text Fragments : linuxChrome",
         "zal:screenResolution": "1440x900"
      },
      "firstMatch": [ {
         "browserName": "chrome",
         "goog:chromeOptions": {

         },
         "platformName": "linux",
         "zal:name": "Doc: table_test.dart - Rich Text - Undo and Redo With Rich Text Fragments : linuxChrome",
         "zal:screenResolution": "1440x900"
      } ]
   },
   "desiredCapabilities": {
      "browserName": "chrome",
      "chromeOptions": {
         "args": [ "window-size=1440,900", "disable-infobars", "enable-precise-memory-info" ],
         "extensions": [ "Q3IyNAIAAAAmAQAAAAEAADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL+fiAlrZV+t
1lIyYR5aqiRRFdH0min2GSjrfwLCQG4tkwXa5Ml4GZRyDG8ymEcu1Xb0/sSYCZ79yzsrbBJsnLJzId/VUr
bdmqy79VbbaXqUlbGDxzf3e7OLjDmBAn23DKXg7..." ],
         "prefs": {
            "download.default_directory": "/home/seluser/exports",
            "download.prompt_for_download": false
         }
      },
      "extendedDebugging": true,
      "goog:chromeOptions": {

      },
      "platform": "LINUX",
      "seleniumProtocol": "WebDriver",
      "zal:name": "Doc: table_test.dart - Rich Text - Undo and Redo With Rich Text Fragments : linuxChrome",
      "zal:screenResolution": "1440x900"
   }
}

Tweaking @seangerhardt-wf capabilities to the below settings will get things working:

Map capabilities = {
      'platform': 'LINUX',
      'browserName': 'chrome',
      'goog:chromeOptions': {
        'args': ['window-size=1280,600', 'disable-infobars', 'enable-precise-memory-info'],
        'prefs': {
          'download': {'default_directory': '/shared/exports/', 'prompt_for_download': 'false'}
        }
      }
    }
  driver = await io.createDriver(desired: capabilities, uri: seleniumUri);

Not sure if this was an intended deviation with Selenium v3.8.0/3.8.1 or not but thought I would post my findings here.

@hijazi
Copy link

hijazi commented Oct 8, 2019

Another important note is to set the absolute path to the directory (I tried relative path and it was ignored), I got the idea form here

@Sitheps
Copy link

Sitheps commented Oct 16, 2019

Me and my colleague got around the relative path problem by converting a relative path into a absolute one.
final String path = Paths.get(".src"+File.separator+"main"+File.separator+"resources"+File.separator+"Folder1").toAbsolutePath().toString();

@steflsd
Copy link

steflsd commented Oct 20, 2019

I got this working by setting the absolute path with a trailing \ at the end. It stops working and defaults to the default dir when going to --headless though. :/

@diemol
Copy link
Member

diemol commented Sep 13, 2020

The problem was the lack of 'goog:chromeOptions', which is needed since already several ChromeDriver versions ago. Closing as the members of the community already gave the needed feedback.

@diemol diemol closed this as completed Sep 13, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants