18

Can a Selenium Grid change the DesiredCaps of the SeleniumClient?

Is their a way to change the values of the Capabilities in the Selenium Grid?

I am already extending the org.openqa.grid.internal.utils.DefaultCapabilityMatcher in a java class to validate some values. Need a way to replace them as well before passing to the Nodes?

  • 1
    Even if such a way exists, you will allocate a Chrome v30 to a client which requested Chrome v26. Doesnt that break the contract? – inquisitive Sep 21 '15 at 06:42
  • 1
    Ummm, that is not exactly the usecase. Actually the user would ask for a "browser code" like give me b2831. Now the hub should replace the b2831 with Google Chrome v31 – Anshuman Chatterjee Sep 21 '15 at 06:56
  • 1
    In that case you will be having a mapping, right? – Shubhasmit Gupta Sep 24 '15 at 06:45
  • 1
    @Shubhasmit Yes, i will have a Mapping, but only on the Machine where SeleniumGrid is present. – Anshuman Chatterjee Sep 25 '15 at 08:08
  • 1
    hub can not do that on it's own, you have to build a logic to do that. – Shubhasmit Gupta Sep 28 '15 at 10:32
  • 1
    Not sure this is even a valid question. Sure: the Grid has default values. BUT: every session thread you start first begins with its own Capabilities object that is part of the RemoteWebDriver instance , which I assume overrides the Node defaults? Of course the node that is selected by the grid will match the browser name and version you selected but I would guess that the other capabilities should override any of the other default options. – djangofan Oct 15 '15 at 16:01

1 Answers1

1

You can build your on custom proxy to do so. In the custom proxy you need to extend the following class: org.openqa.grid.selenium.proxy.DefaultRemoteProxy and override beforeSession function which has TestSession object as a parameter, from where you can get the capabilities. While registering your node you need to specify the new proxy and start the hub with new custom proxy.