-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[java] avoid ClassCastException for unexpected driver responses #16389 #16681
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
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨No code suggestions found for the PR. |
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
User description
🔗 Related Issues
Improves the error message to better debug #16389
💥 What does this PR do?
Avoid the unchecked cast and fail with a
WebDriverExceptionas this should be a driver issue.🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Bug fix
Description
Removes unchecked casts that could cause ClassCastException
Validates driver response is WebElement before processing
Throws WebDriverException with helpful hint on invalid response
Improves error debugging for unexpected driver responses
Diagram Walkthrough
flowchart LR A["Driver Response"] --> B["Type Check"] B --> C{Is WebElement?} C -->|Yes| D["Process Element"] C -->|No| E["Throw WebDriverException<br/>with hint"]File Walkthrough
ElementLocation.java
Add type validation and error handling for driver responsesjava/src/org/openqa/selenium/remote/ElementLocation.java
(WebElement)infindElement()methodListcast toListinfindElements()methodmassage()method to validate response is WebElement instanceresponses