Skip to content

WebElement API flexibility: cannot extend findElements(By) #934

@mfulton26

Description

@mfulton26

I want to extend WebElement in my library but the signature for findElements(By) is causing me trouble:

List<WebElement> findElements(By by);

Compiling a class, ExtendedWebElement, that implements WebElement and overrides findElements(By) using a different return type, i.e. List<ExtendedWebElement> findElements(By by);, produces the following error message:
[ERROR] return type java.util.List<com.example.selenium.ExtendedWebElement> is not compatible with java.util.List<org.openqa.selenium.WebElement>

Can we change the signature to use a bounded wildcard to increase API flexibility?

List<? extends WebElement> findElements(By by);

If so then it will be much more flexible (e.g. extensible). Thank you.

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