selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🐛 Bug]: Selenium Grid cannot create a session without --enable-managed-downloads true

Open eugenedani opened this issue 1 year ago • 8 comments
trafficstars

What happened?

Run Selenium server as a standalone or hub/node without --enable-managed-downloads true parameter for example, java -jar /root/selenium-server-.jar standalone

Run a Selenium for any download files supported browser with driver option setEnableDownloads(true)

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

Is it a bug or expected behavior? If this is expected behavior could error exception be more informative? For example, say something about --enable-managed-downloads parameter

How can we reproduce the issue?

Run Selenium server as a standalone or hub/node without --enable-managed-downloads true parameter
for example, java -jar /root/selenium-server-<version>.jar standalone

Run a Selenium test for any download files supported browser with driver option setEnableDownloads(true)

for example
`ChromeOptions options = new ChromeOptions();
options.setEnableDownloads(true);
WebDriver driver = new RemoteWebDriver(new URL("http://gridUrl:4444"), chromeOptions);

Relevant log output

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Host info: host: 'host', ip: '1xx.1xx.1.79'
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:232)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:161)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:147)
Caused by: org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.21.0', revision: '79ed462ef4'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.6'
Driver info: driver.version: DelegatingWebDriver
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute0(JdkHttpClient.java:399)
	at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
	at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:55)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute(JdkHttpClient.java:355)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:89)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:61)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:162)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
	... 54 more
Caused by: java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute0(JdkHttpClient.java:382)
	... 62 more

Operating System

Window, Linux

Selenium version

4.21.0

What are the browser(s) and version(s) where you see this issue?

Chrome 126, Edge 125, Firefox ESR 115.12.0

What are the browser driver(s) and version(s) where you see this issue?

Chrome WebDriver 126.0.6478.55, Gecko 0.34.0

Are you using Selenium Grid?

4.21.0

eugenedani avatar Jun 12 '24 12:06 eugenedani

@eugenedani, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] avatar Jun 12 '24 12:06 github-actions[bot]

The capabilities you pass in are telling the grid to only provide a session with those capabilities. When options.setEnableDownloads(true) The grid can't satisfy the session request because it wasn't enabled.

Is this the right error message for that? Can it be improved? Maybe someone with more grid understanding can answer.

titusfortner avatar Jun 12 '24 12:06 titusfortner

I supposed setEnableDownloads(true) should not have influence on session creation. I expect it will just ignore this option for this case.

If my expectation is not right then I would expect more informative error message. I spent couple of hours before I found out the problem

eugenedani avatar Jun 12 '24 12:06 eugenedani

Or possible error can be noted in documentation

eugenedani avatar Jun 12 '24 12:06 eugenedani

Amy time you ask for a session with a capability that the grid cannot satisfy it should error. Hopefully we can improve the error message.

titusfortner avatar Jun 12 '24 13:06 titusfortner

Thank you for explanation It would be great to have better error message.

eugenedani avatar Jun 12 '24 13:06 eugenedani

This issue is looking for contributors.

Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.

github-actions[bot] avatar Jul 12 '24 08:07 github-actions[bot]

@titusfortner In the case of error messages, more information is better. Unfortunately, DefaultSlotMatcher is only able to return true or false from its matches(Capabilities, Capabilities) method. The specific capability mismatch that causes any given slot to be rejected is neither recorded nor reported. The other challenge is that a Grid instance can be expected to provide multiple slots that supply a variety of different types of sessions. The only way I can think of to provided more detailed diagnostic information would be to collect the details of each mismatch, returning this information in the exception if none of the available slots is able to satisfy the "new session" request.

sbabcoc avatar Oct 01 '24 23:10 sbabcoc

This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Mar 31 '25 10:03 github-actions[bot]