Skip to content

WebElement cannot be wrapped in a Proxy #3047

Closed
@nebehr

Description

@nebehr

Sometimes it is necessary to wrap a WebElement in a proxy - the most obvious choice could be java.lang.reflect.Proxy. However, existing implementation does not allow to use such proxied WebElements as arguments in the calls to JavascriptExecutor.executeScript().

Normally Proxy instance is created by specifying a set of interfaces that it should implement, but in WebElementToJsonConverter.apply() (https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/remote/internal/WebElementToJsonConverter.java#L53) which is used from executeScript() there is a test for a RemoteWebElement concrete class which proxy obviously cannot model.

One way to circumvent this would be to have proxy implement WrapsElement, but it would require additional logic to distinguish between invocations of WrapsElement methods and everything else. Would it be possible in WebElementToJsonConverter to test for HasIdentity instead of RemoteWebElement? I am not sufficiently familiar with Selenium's internal API but it does not look unreasonable to me on first glance.

Pertains both to Selenium 3.0 and earlier versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-javaJava Bindings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions