Skip to content

fix: stop using deprecated HttpCommandExecutor and BiDi APIs from Selenium 4.50 - #2458

Draft
diemol wants to merge 2 commits into
appium:masterfrom
diemol:stop-using-http-command-executor-fields
Draft

diemol wants to merge 2 commits into
appium:masterfrom
diemol:stop-using-http-command-executor-fields

Conversation

@diemol

@diemol diemol commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Change list

  • Bump Selenium to 4.50.0.
  • AppiumCommandExecutor keeps its own HttpClient.Factory and uses the new HttpCommandExecutor(HttpClient, Map, URL) constructor.
  • AppiumCommandExecutor.getClient() is now public, so AppiumDriver no longer reads HttpCommandExecutor.client.
  • The server URL now comes from AppiumClientConfig or AppiumDriver.getRemoteAddress(), not from getAddressOfRemoteServer().
  • AppiumDriver overrides getHandle(), which is the new way Selenium gives BiDi access.
  • No more reflection on HttpCommandExecutor.client:
    • Direct connect switches the target of a small wrapper client (SwitchableHttpClient) instead of replacing the field. The old client is now closed.
    • If someone passes their own HttpCommandExecutor, AppiumDriver creates its own HTTP client for the log websockets (same as BiDi already does) and closes it on quit().

Types of changes

What types of changes are you proposing/introducing to Java client?
Put an x in the boxes that apply

  • No changes in production code.
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Details

Selenium 4.50 deprecated some HttpCommandExecutor fields and methods that Appium uses (SeleniumHQ/selenium#18038, SeleniumHQ/selenium#18098). In Selenium 4.52, client becomes protected and httpClientFactory is removed. Without this change, Appium would break with Selenium 4.52.

Notes:

  • The minimum Selenium version is now 4.50.0, because the new constructor only exists from that version.
  • getBiDi() and maybeGetBiDi() stay. Selenium deprecated them, but it has no replacement yet for listeners on one browsing context, such as NATIVE_CONTEXT.
  • getAddressOfRemoteServer() is still called only when someone passes their own HttpCommandExecutor (not Appium's). Selenium has no replacement for that case.
  • After this change, the build has no deprecation warnings from Selenium.

🤖 Generated with Claude Code

diemol and others added 2 commits October 1, 2026 14:54
…enium 4.50

Selenium 4.50 deprecates HttpCommandExecutor.client (public access),
httpClientFactory, the factory-based constructors and
getAddressOfRemoteServer(). It also deprecates HasBiDi.getBiDi() and
maybeGetBiDi() in favour of getHandle().

- Bump Selenium to 4.50.0 and use the new HttpCommandExecutor(HttpClient,
  Map, URL) constructor.
- Keep our own HttpClient.Factory in AppiumCommandExecutor and make
  getClient() public, so AppiumDriver no longer reads the fields.
- Get the server URL from AppiumClientConfig / AppiumDriver.getRemoteAddress().
- Override getHandle(), and keep getBiDi()/maybeGetBiDi() for users since
  Selenium has no replacement for context-scoped listeners yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… client

- Direct connect now switches the target of a SwitchableHttpClient that
  AppiumCommandExecutor passes to Selenium, instead of replacing the
  final client field by reflection. The previous client is closed.
- For executors that are not AppiumCommandExecutor, AppiumDriver creates
  its own HTTP client for log websockets (as BiDi already does) and
  closes it on quit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@diemol

diemol commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

I am leaving this parked for a while since the current code does not look good. I made a couple of changes in Selenium to improve this PR but I need to wait for 4.51 to be released. If it is ok with you, please leave this PR open and I will come back to it after the next Selenium release.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant