appium / appium/java-client

Make Widget implement WebElement

Open
#1,160 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
1.3k
Forks
752
Avg merge
6d 21h
Merged PRs (30d)
8

Description

Description

Since Widget does not implement WebElement along with WrapsElement, it makes calls to the WebElement methods require a verbose call to getWrappedElement every time an interaction is needed. It would be a simple fix to have Widget implement this interface and delegate to the underlying element.

Environment

n/a

Details

I tried to extend Widget and implement WebElement in the subclass, but there's a type-erasure issue because of the implementation of findElement(By By)

Code To Reproduce Issue [ Good To Have ]

public Class MyWidget extends Widget implements WebElement {
    // WebElement interface requires a generic here, but Widget does not
    @Override
    public <T extends WebElement> T findElement(By by) {
        return element.findElement(by);
    }
}

Ecxeption stacktraces

Error:(65, 43) java: name clash: findElement(org.openqa.selenium.By) in MyWidget and findElement(org.openqa.selenium.By) in io.appium.java_client.pagefactory.Widget have the same erasure, yet neither overrides the other

Link to Appium logs

n/a

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Widget entry point, its findElement(By) method, and getWrappedElement; compare their signatures with WebElement and the reproduction shown in the issue. Done means Widget can be used as a WebElement without the reported type-erasure error, with delegated interactions covered by the relevant existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.