Maybe I’m not on the right track and I don't know how to understand better. I think the decorator is not what I am looking for.
My idea is I want to create my own methods for any Element and those methods I will use for locators to interact with it. The driver will have his own methods too.
This is one of example which probably I will use:
Before it clicks on an element it has something to happen to be sure there is an element I am looking for, for example above to wait for elementToBeClickable
, to be presented in DOM, stale element, or anything else to help me to avoid possible exceptions. I don't want just to call Selenium's WebDriver and to click() on an element. In a similar direction, it will work with other Element's methods.
I thought decorator pattern can be useful if some methods in some situation for some element on a page doesn't work jobs well to override over ElementDecorator and to use it in that specific situation. I didn't try this in practice. That was on my mind when I start to explore how to do this. I don't have enough experience to resolve is this good or not.
I hope I have explained a little better what I want to achieve.
If you don't like the API provided by WebDriver and WebElement, you can of course provide your own façade that wraps around those classes, but you wouldn't need a custom subclass for every different type of browser. In that case, just rename WebDriverDecorator to SeleniumDriverFacade and make it final. You can then also get rid of Element and all its subtypes, and just return WebElement.
Could you please show me this in a small example to be sure I understood you?