-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
#16573 unwrap double-wrapped webdriver #16575
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
base: trunk
Are you sure you want to change the base?
#16573 unwrap double-wrapped webdriver #16575
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 |
||||||||||||||||||||||||||||||
|
Thank you, @asolntsev for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent After reviewing the change, unless it is a critical fix or a feature that is needed for Selenium We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
392fcb6 to
107b41b
Compare
107b41b to
363c915
Compare
| (instance) -> | ||
| (proxy, method, args) -> { | ||
| if ("getWrappedDriver".equals(method.getName())) { | ||
| if (sample instanceof WrapsDriver || "getWrappedDriver".equals(method.getName())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should the method name be ignored for a WrapsDriver instance? WrapsDriver does only has this one method, but this might change over time. Or some generic methods e.g. .hashCode() could be called?
User description
🔗 Related Issues
Fixes #16573
💥 What does this PR do?
Fix
WebDriverDecoratorto properly decorate WebDriver instance that is already decorated.🔄 Types of changes
Test
I have a test, but not sure where to put it in Selenium project codebase:
PR Type
Bug fix
Description
Fix WebDriverDecorator to properly unwrap double-wrapped WebDriver instances
Recursively unwrap WrapsDriver to find the original driver implementation
Handle WrapsDriver interface in deriveAdditionalInterfaces method
Prevent infinite loops and hanging when decorating already-decorated drivers
Diagram Walkthrough
File Walkthrough
WebDriverDecorator.java
Unwrap double-wrapped WebDriver instances recursivelyjava/src/org/openqa/selenium/support/decorators/WebDriverDecorator.java
unwrapOriginal()method to recursively unwrap WrapsDriverinstances until reaching the original driver
Definitionconstructor to useunwrapOriginal()instead ofdirectly calling
getOriginal()deriveAdditionalInterfaces()to handle already-wrapped driversby checking if sample is WrapsDriver
driver when sample is already wrapped