Skip to content

Enable extension of RemoteWebDriver and HttpCommandExecutor #3801

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

Closed
wants to merge 2 commits into from

Conversation

iddol
Copy link

@iddol iddol commented Apr 9, 2017

The ability to implement sub-classes of RemoteWebDriver and
HttpCommandExecutor in the Java client is very limited, since these
classes have private data members, with no protected accessors.
In order to increase the extensibility of these classes, protected
accessors were added, and methods that accessed these fields directly
were changed to use these accessors.

The fields that are now accessible by sub-classes are:
RemoteWebDriver.capabilities
HttpCommandExecutor.commandCodec
HttpCommandExecutor.responseCodec
HttpCommandExecutor.client

The ability to implement sub-classes of RemoteWebDriver and
HttpCommandExecutor in the Java client is very limited, since these
classes have private data members, with no protected accessors.
In order to increase the extensibility of these classes, protected
accessors were added, and methods that accessed these fields directly
were changed to use these accessors.

The fields that are now accessible by sub-classes are:
RemoteWebDriver.capabilities
HttpCommandExecutor.commandCodec
HttpCommandExecutor.responseCodec
HttpCommandExecutor.client
@mach6 mach6 requested a review from shs96c April 10, 2017 04:52
@mach6 mach6 added the C-java Java Bindings label Apr 10, 2017
The ability to implement sub-classes of RemoteWebDriver and
HttpCommandExecutor in the Java client is very limited, since these
classes have private data members, with no protected accessors.
In order to increase the extensibility of these classes, protected
accessors were added, and methods that accessed these fields directly
were changed to use the new accessors.

The fields that are now accessible by sub-classes are:
RemoteWebDriver.capabilities
HttpCommandExecutor.commandCodec
HttpCommandExecutor.responseCodec
HttpCommandExecutor.client
@shs96c
Copy link
Member

shs96c commented Jan 11, 2018

My apologies for the slow reply. Can I ask why you're attempting to subclass the HttpCommandExecutor? I can understand wanting to expose the fields, but it would be helpful to better understand the motivation.

@shs96c shs96c added J-awaiting answer Question asked of user; a reply moves it to triage again I-question Applied to questions. Issues should be closed and send the user to community resources. labels Jan 11, 2018
@iddol
Copy link
Author

iddol commented Jan 11, 2018

The motivation for this was the need to support distribution of the driver across multiple nodes in a cluster. We create the driver in one node, but the operations we perform on the driver may be redirected to another node. So we need a way to serialize the session in the node that creates the driver, store it in a distributed location (e.g., Redis), and then deserialize it in some other nodes and continue working on the same session.

The serialization and deserialization parts are simple, because all the data we need in order to reconstruct an existing session is serializable in nature (session key, remote address URL, capabilities). The challenge was to how to create a driver object using that data. So we extended the standard driver with a proprietary implementation that exposes a constructor that accepts the data of an existing session. This constructor initializes the driver by using the given session key and capabilities instead of calling the server to create a new session. This is why we needed access to the capabilities data member.

However, when we did that the codecs on the command executor were not initialized, so we had to initialize them explicitly. This is why we needed access to the codecs data members.

I realize this is not a very standard use case, so I hope I managed to explain this clearly enough. If you have some idea of a better way to create a driver for an existing session we will be happy to hear your suggestions.

@iddol
Copy link
Author

iddol commented Mar 17, 2018

Hi @shs96c, any chance of these changes being incorporated into one of the upcoming Selenium versions?

@mrtduzgun
Copy link

++

@CLAassistant
Copy link

CLAassistant commented Nov 23, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@AutomatedTester
Copy link
Member

Thank you for the effort that you have put into this PR. The system is designed that you can pass in your own executor when you want and is extensible through that means. I suggest taking advantage of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-java Java Bindings I-question Applied to questions. Issues should be closed and send the user to community resources. J-awaiting answer Question asked of user; a reply moves it to triage again
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants