Skip to content

Cannot extend AppiumCommandExecutor after upgrading to version 6 #920

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
iddol opened this issue May 29, 2018 · 3 comments
Closed

Cannot extend AppiumCommandExecutor after upgrading to version 6 #920

iddol opened this issue May 29, 2018 · 3 comments

Comments

@iddol
Copy link

iddol commented May 29, 2018

Description

We have a class that extends AppiumCommandExecutor, and it stopped working when we tried to upgrade to version 6. The implementation of getPrivateFieldValue() and getPrivateFieldValue() assumes that the the requested fields (e.g., commandCodec, responseCodec, additionalCommands, client) are defined on the direct super-class of the current class, so when we use our sub-class these methods fail, because the requested fields are located on a super-class two levels up in the repository.

Environment

  • java-client version 6.0.0

Details

When we try to create a new driver, using our class that extends AppiumCommandExecutor, the call to createSession() fails, because getCommandCodec() looks for a private fields on the direct parent of the current class. The implementation assumes that the direct parent is HttpCommandExecutor, but in our case the direct parent is AppiumCommandExecutor, and HttpCommandExecution is an indirect parent. Unfortubnately, All the methods in AppiumCommandExecutor are private, so our sub-class cannot override them to change the behvior defined above.

In order to enable us to work with version 6, at least one of the following changes is required:

  1. Make the methods in AppiumCommandExecutor protected, so we can override them.

  2. Change the implementation of getPrivateFieldValue() and setPrivateFieldValue() to support extension: Instead of looking for the field in the direct super-class, look for it anywhere in the class hierarhcy.

By the way, a year ago we submitted a pull request to the Selenium project (SeleniumHQ/selenium#3801) to enable extending their RemoteWebDriver and HttpCommandExecutor without having to use reflection, but it was not approved.

Exception stacktraces

https://gist.github.com/iddol/dc23b7c87c267a4f88efeaac04e62cd8

@mykola-mokhnach
Copy link
Contributor

@iddol Please check if #928 works for you

@iddol
Copy link
Author

iddol commented Jun 2, 2018

Yes, I believe it does, thank you!
It would be helpful to make the other private setters and getters (e.g., setResponseCodec(), setCommandCodec() protected as well, so the sub-class can use them instead of calling setPrivateFieldValue().

@iddol
Copy link
Author

iddol commented Jun 7, 2018

The other API were also changed to protected as part of #928, which was reviewed and merged, so we can now close this issue.

@iddol iddol closed this as completed Jun 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants