Conversation
…tionType(String) getExceptionType(String) returned null for any state that is not a mobile-specific error, while getExceptionType(int) delegates to super. Selenium is moving ErrorHandler from the JSON Wire integer status to the W3C state string (SeleniumHQ/selenium#18059), after which every standard error (e.g. "no such element") would resolve to null and surface as a plain WebDriverException instead of its specific type. Delegate unmatched states to super, and guard against a null state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
diemol
requested review from
SrinivasanTarget,
mykola-mokhnach,
saikrishna321 and
valfirst
as code owners
September 23, 2026 09:50
Author
|
I was going to merge the linked PR but Claude found that this would break Appium's errors codes. I will merge the PR in Selenium and I hope you folks can do a release soon with this change. |
Contributor
|
Thanks @diemol It looks like the compatibility with the latest snapshot is already broken: https://github.com/appium/java-client/actions/runs/35845286236/job/107136595938, so only this change won't be enough to keep it compatible |
| * @return The exception type that corresponds to the provided error message. | ||
| */ | ||
| @Override | ||
| public Class<? extends WebDriverException> getExceptionType(String message) { |
Contributor
There was a problem hiding this comment.
please mark message arg as nullable
mykola-mokhnach
approved these changes
Sep 23, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change list
ErrorCodesMobile.getExceptionType(String)now callssuper.getExceptionType(...)for states that don't match a mobile-specific error, instead of returningnull.nullcheck on the incoming state to avoid aNullPointerExceptionatmessage.contains(...).ErrorCodesMobileTestunit tests.Types of changes
What types of changes are you proposing/introducing to Java client?
Put an
xin the boxes that applyDetails
ErrorCodesMobileoverrides both lookup methods from Selenium'sErrorCodes, but they behave differently:getExceptionType(int)handlesNO_SUCH_CONTEXTand delegates everything else tosuper.getExceptionType(String)handles"No such context found"and returnsnullfor everything else.Until now this didn't matter, because Selenium's
ErrorHandler(whichAppiumDriverinstalls withnew ErrorHandler(new ErrorCodesMobile(), true)) resolved exceptions using the integer status. Selenium is movingErrorHandlerto the W3Cstatestring instead (SeleniumHQ/selenium#18059, part of removing JSON Wire Protocol leftovers in SeleniumHQ/selenium#17638). After that change, every standard error, such as"no such element"or"stale element reference", would getnullfrom this method. Appium users would then see a plainWebDriverExceptioninstead ofNoSuchElementException,StaleElementReferenceExceptionand so on, which breakscatchblocks and waits that rely on the specific type.With this change, the String lookup behaves the same way as the int lookup:
The new tests fail on the current code (
expected: NoSuchElementException but was: null) and pass with this fix.Selenium will keep a fallback for existing Appium releases on its side, so this isn't urgent, but it makes the method correct for the upcoming change.
🤖 Generated with Claude Code