yandex-qatools/htmlelements

Nested typified elements

iamanikeev opened this issue · 2 comments

Hi,

I am using TypifiedElement as a base class, from which I extend my own elements, that partially use Yandex methods. Some methods are overridden because application that is being tested has its own makeup specifics. The issue is as follows:

F.e. there is an element that has some inner elements inside it :

public class CustomElement extends TypifiedElement {

    @FindBy(xpath = ".//input[@class='innerInput']")
    private TextInput innerTextInput;
}

This element, it its turn is being placed on a page, and also has a @FindBy (and|or) @Name annotations. When a page with such element is being loaded via Yandex pagefactory constructor, e.g., like this:

public CustomPage(WebDriver driver) {
        PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(driver)), this);
    }

Inner elements are not being initialized properly (they stay null), so I cannot interact with them. In case if I inherit my custom element from HtmlElement class, it behaves like I expect it to, but there are too much public methods in HtmlElement, that are not meant to be in the custom element.

So the question is: is this a valid use case, or I am using the htmlelements wrong? Also, in case if this kind of usage is valid, is it possible to implement nested elements initialization in your pagefactory? I could do a pull request for that, if so. Thanks in advance!

calling populatePageObject(instance, elementToWrap); after this line does the trick.

Initially we think of TypifiedElement as simple, basic elements constructing page. We usually extend HtmlElements when describing complex blocks with inner structure. Actually there is no much difference between two and i think bringing the idea of TypifiedElement was wrong from the very beginning. We will probably get rid of it in the future.