Skip to content
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

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

Closed
mfulton26 opened this issue Aug 17, 2015 · 3 comments
Closed

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

mfulton26 opened this issue Aug 17, 2015 · 3 comments
Labels

Comments

@mfulton26
Copy link

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.

@jleyba
Copy link
Contributor

jleyba commented Aug 17, 2015

See pull request #863

@mfulton26
Copy link
Author

I like it. <T extends WebElement> List<T> findElements(By by); is, I think, even better than List<? extends WebElement> findElements(By by); as the latter would force users to use wildcard types in client code and the prior does not. Thanks!

yiming-tang-cs pushed a commit to ponder-lab/selenium that referenced this issue Jan 2, 2020
…reads.

Also-by: Achim Kraus <achim.kraus@bosch-si.com>
yiming-tang-cs pushed a commit to ponder-lab/selenium that referenced this issue Jan 2, 2020
@diemol
Copy link
Member

diemol commented May 19, 2020

Closing this issue since all the discussion was done in the PR, in addition, the PR was not merged but its purpose was achieved in the end through the implementation of generics in the Java bindings for Appium.

@diemol diemol closed this as completed May 19, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants