@Override
public TestSession getNewSession(Map<String, Object> requestedCapability) {
options = new HashMap<>();
options.put("args", Arrays.asList("--proxy-server=localhost:8080"));
requestedCapability.put(ChromeOptions.CAPABILITY, options);
return super.getNewSession(requestedCapability);
}
Jun 13, 2017 12:50:54 AM org.openqa.grid.web.servlet.handler.RequestHandler process
INFO: Got a request to create a new session: Capabilities [{browserName=chrome, version=, platform=ANY}]
Jun 13, 2017 12:50:54 AM org.openqa.selenium.remote.server.SessionCleaner <init>
INFO: SessionCleaner initialized with insideBrowserTimeout 0 and clientGoneTimeout 1800000 polling every 180000
Jun 13, 2017 12:50:55 AM org.openqa.grid.internal.TestSlot getNewSession
INFO: Trying to create a new session on test slot {browserName=chrome, maxInstances=1, version=, platform=ANY}
Jun 13, 2017 12:50:55 AM org.openqa.selenium.remote.server.rest.ResultConfig handle
INFO: Executing: [new session: Capabilities [{browserName=chrome, version=, platform=ANY}]])
Jun 13, 2017 12:50:55 AM org.openqa.selenium.remote.server.DefaultDriverProvider newInstance
INFO: Creating a new session for Capabilities [{browserName=chrome, version=, platform=ANY}]
Starting ChromeDriver 2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41) on port 31592
Only local connections are allowed.
Jun 13, 2017 12:50:57 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Jun 13, 2017 12:50:57 AM org.openqa.selenium.remote.server.rest.ResultConfig handle
INFO: Done: [new session: Capabilities [{browserName=chrome, version=, platform=ANY}]]
Jun 13, 2017 12:50:57 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
ChromeOptions options = new ChromeOptions();
options.addArguments("--proxy-server=localhost:8080");
DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setCapability(ChromeOptions.CAPABILITY, options);
driver = new RemoteWebDriver(hub.getWebDriverHubRequestURL(), caps);
Jun 13, 2017 1:16:04 AM org.openqa.grid.web.servlet.handler.RequestHandler process
INFO: Got a request to create a new session: Capabilities [{browserName=chrome, chromeOptions={args=[--proxy-server=localhost:8080], extensions=[]}, version=, platform=ANY}]
Jun 13, 2017 1:16:04 AM org.openqa.selenium.remote.server.SessionCleaner <init>
INFO: SessionCleaner initialized with insideBrowserTimeout 0 and clientGoneTimeout 1800000 polling every 180000
Jun 13, 2017 1:16:05 AM org.openqa.grid.internal.TestSlot getNewSession
INFO: Trying to create a new session on test slot {browserName=chrome, maxInstances=1, version=, platform=ANY}
Jun 13, 2017 1:16:05 AM org.openqa.selenium.remote.server.rest.ResultConfig handle
INFO: Executing: [new session: Capabilities [{browserName=chrome, chromeOptions={args=[--proxy-server=localhost:8080], extensions=[]}, version=, platform=ANY}]])
Jun 13, 2017 1:16:05 AM org.openqa.selenium.remote.server.DefaultDriverProvider newInstance
INFO: Creating a new session for Capabilities [{browserName=chrome, chromeOptions={args=[--proxy-server=localhost:8080], extensions=[]}, version=, platform=ANY}]
Starting ChromeDriver 2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41) on port 47865
Only local connections are allowed.
Jun 13, 2017 1:16:07 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Jun 13, 2017 1:16:07 AM org.openqa.selenium.remote.server.rest.ResultConfig handle
INFO: Done: [new session: Capabilities [{browserName=chrome, chromeOptions={args=[--proxy-server=localhost:8080], extensions=[]}, version=, platform=ANY}]]
Jun 13, 2017 1:16:07 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
You are not looking at this properly. The line
Jun 13, 2017 12:50:54 AM org.openqa.grid.web.servlet.handler.RequestHandler process
INFO: Got a request to create a new session: Capabilities [{browserName=chrome, version=, platform=ANY}]
Is shown when the Grid receives a new session request but before the session is created.
So this line is being printed even before your call to org.openqa.grid.internal.BaseRemoteProxy#getNewSession which is where your logic of adding/altering the capabilities is being invoked.
The way to identify this properly is by setting a breakpoint in your test code such that the code execution stops after the RemoteWebDriver instance is created [ which would mean that a browser was spun off at this point in the remote host at the node side], and then manually inspecting the browser’s settings (The one that was opened by your test code in your node) to see if the proxy settings were applied properly.
On a side note, I would be curious to know as to why would you want to inject proxy settings at the node level ? This would essentially cause your node to end up injecting the BMP proxy server for every new session (which means its done for every test) whereas if you do it when you are instantiating a new RemoteWebDriver instance, you have the choice of doing it based on your need.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/51acf7a5-bac3-4c74-aa94-a58144f3840c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ok.. I spent some more time looking at the code. I don’t think what you are trying is going to work.
The capabilities map that gets exposed to you via the Proxy is an extracted copy of the original InputStream that’s embedded within the javax.servlet.http.HttpServletRequest (Remember your RemoteWebDriver instance eventually creates a HttpServletRequest
So in the grand scheme of things, what you are modifying, is a copy of the actual capability. The actual capability is still part of the original HttpServletRequest that your RemoteWebDriver instance forwarded to the Hub and which gets sent as is to the elected proxy node.
So you would need to change your logic and do one of the following :
I hope that explains the rationale behind the behavior you are currently seeing.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/595badee-f10a-410a-ba37-6b6539a19c09%40googlegroups.com.
Not sure what is the question. The beforeSession() is meant to act as a listener in the grid wherein it let's you do something before the session begins.
Excellent question! Unfortunately I don’t have the answer. My best guess is that the capability object is being exposed in the createSession() only to facilitate an easy inspection of what is being desired by the end user, so that some tweaks if necessary can be taken up. For e.g., if one were to be building an on-demand Grid wherein there are no nodes, but everything is backed by a docker end-point, one would need to inspect the incoming capability to decide what sort of a docker container needs to be spun off before forwarding the new session to it. Or maybe one would want to switch on a VM and have it ready before the new session request can be forwarded to it.
Whatever I have told you so far, is all based on my experiences with the grid and by looking at the codebase.
I think currently the updates being made to the capabilities object via the beforeSession() method might actually be dead code and may not even be working (I am yet to vet out this theory, but that’s my observation).
Here’s the chain of events based on which I am saying this :
So in all these events, the desiredCapability which is extracted out of an incoming HttpServletRequest (from step 1) inside a variant of SeleniumBasedRequest is NOT referred anywhere when it comes to forwarding it to the node.
That is why I say that the code within org.openqa.grid.selenium.proxy.DefaultRemoteProxy#beforeSession which is updating the TestSession’s map is perhaps dead code.
You can quickly cross check this theory by nullifying this method in your customized proxy and run a test which sets one of the following via the capabilities object when instantiating a RemoteWebDriver:
If you have turned on debug level logs at the node side, you would perhaps notice that the incoming capability object would still have these keys in it.
For your use-case, I would recommend that you resort to adding the proxy at the client side where the RemoteWebDriver is being instantiated. That’s easier to manage. If you have a framework, you can inject this information at the part wherein the RemoteWebDriver is being instantiated.
If you still feel that this perhaps makes no sense and what is being updated in a TestSession as its capability is what should be forwarded to the node by the DefaultRemoteProxy, then you can raise a bug against the selenium codebase.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7b073d46-4fd7-499e-b779-3e4e189fa554%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/05890dce-b1f4-47a9-a1f0-8523d3e1dad5%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
This was a bug and I went about fixing this issue and have sent out a pull request.
PR : https://github.com/SeleniumHQ/selenium/pull/4196
Fingers crossed! Let’s hope it gets vetted out and merged.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
From: <seleniu...@googlegroups.com> on behalf of <msar...@gmail.com>
Reply-To: <seleniu...@googlegroups.com>
Date: Saturday, June 17, 2017 at 7:24 AM
To: Selenium Users <seleniu...@googlegroups.com>
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/40694874-1d90-41fb-85ba-7091e77d3a74%40googlegroups.com.