Skip to content

Composition instead of Inheritance might help with leveraging WebElement #6

Open
@sidnc86

Description

@sidnc86

In Issue#3, we asked for inheriting from WebElement by implementing the entire interface. An easier approach could be to leverage the instance behind the WebElement interface by using composition. In CustomWebElement constructor, we can for example maintain a WebElement reference right away. Then within implementation of methods like getAttribute(), we can do following:

public String getAttribute(String attributeName) {
    return this.webElemRef.getAttribute(attributeName);
}

Instead of the existing implementation which is like follows:

public String getAttribute(String attributeName) {
    return getWebDriver().findElement(getBy()).getAttribute(attributeName);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions