Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,15 @@ protected static class Definition {

public Definition(Decorated<?> decorated) {
this.decoratedClass = decorated.getClass();
this.originalClass = decorated.getOriginal().getClass();
this.originalClass = unwrapOriginal(decorated).getClass();
}

private static Object unwrapOriginal(Decorated<?> decorated) {
Object original = decorated.getOriginal();
while (original instanceof WrapsDriver) {
original = ((WrapsDriver) original).getWrappedDriver();
}
return original;
}

@Override
Expand Down Expand Up @@ -480,12 +488,12 @@ private static void extractInterfaces(final Set<Class<?>> collector, final Class
private <Z> Map<Class<?>, Function<Z, InvocationHandler>> deriveAdditionalInterfaces(Z sample) {
Map<Class<?>, Function<Z, InvocationHandler>> handlers = new HashMap<>();

if (sample instanceof WebDriver && !(sample instanceof WrapsDriver)) {
if (sample instanceof WebDriver) {
handlers.put(
WrapsDriver.class,
(instance) ->
(proxy, method, args) -> {
if ("getWrappedDriver".equals(method.getName())) {
if (sample instanceof WrapsDriver || "getWrappedDriver".equals(method.getName())) {
Copy link
Member

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?

return instance;
}
throw new UnsupportedOperationException(method.getName());
Expand Down
Loading