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

Composition instead of Inheritance might help with leveraging WebElement #6

Open
sidnc86 opened this issue Jul 12, 2019 · 0 comments
Open

Comments

@sidnc86
Copy link

sidnc86 commented Jul 12, 2019

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant