0

I am getting this error message thrown

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

when I set the capability to download files from the grid nodes.

If I comment out options.setCapability("se:downloadsEnabled", "true") the browser launches with the session created.

if (browser.equalsIgnoreCase("chrome")) {
                ChromeOptions options = new ChromeOptions();
                options.setCapability("platformName", Platform.LINUX);                  
                options.setCapability("se:downloadsEnabled", true); // Works when commented             
                HashMap<String, Object> chromePref = new HashMap<>();               
                chromePref.put("plugins.always_open_pdf_externally", Boolean.valueOf(true));
                chromePref.put("download.prompt_for_download", Boolean.valueOf(false));
                chromePref.put("safebrowsing_for_trusted_sources_enabled", oolean.valueOf(false));
                options.setExperimentalOption("prefs", chromePref);             
                driver = new RemoteWebDriver(new URL("http://localhost:4444/"), options);

}
  • Chrome browser:114.0
  • Selenium: 4.9.0
  • ChromeDriver 114.0.5735.90

I'd appreciate any help from anyone.

Thanks

tedtrain
  • 23
  • 2
  • 6

2 Answers2

1

se:downloadsEnabled

se:downloadsEnabled is only in Grid configuration which is used to set the capability at the test level as follows:

options.setCapability("se:downloadsEnabled", true);

se:downloadsEnabled when set to true within a Grid infrastructure will try to match a session request with se:downloadsEnabled against only those nodes which were started with --enable-managed-downloads set to true. If a session is matched, then the Node automatically sets the required capabilities to let the browser know, as to where should a file be downloaded.

Then only the Node will allow a user to:

  • List all the files that were downloaded for a specific session
  • Retrieve a specific file from the list of files.

However, the directory into which files were downloaded for a specific session gets automatically cleaned up when the session ends (or) timesout due to inactivity.

Note: Currently this capability is supported only on:

  • Edge
  • Firefox
  • Chrome
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks for your response. How do I set **--enable-managed-downloads** to **true** using docker-compose? I use docker-compose to start up my hub and node. – tedtrain Jul 18 '23 at 21:26
0

I figured it out. In your docker-compose.yml file under the environment, add

- SE_OPTS=--enable-managed-downloads true
K.Mat
  • 1,341
  • 11
  • 17
tedtrain
  • 23
  • 2
  • 6