How to cascade FluentPage and FluentWebElement

28 views
Skip to first unread message

Michael Kunze

unread,
Mar 7, 2016, 8:09:20 AM3/7/16
to FluentLenium
Hi there,

so i have a problem to design my pages and elements properly. As you can't access the webpage i'm testing i have to use code samples.

public class SomePage extends FluentPage {
   
@FindBy(css = ".someClass")
   
FluentList<SomePageFragment> somePageFragments;
}

So first of all i start with a basic page which has a couple of fragments on it (rows or whatever), doesn't really matter.
To make this even work i need to extend FluentWebElement
public class SomePageFragment extends FluentWebElement {
   @FindBy(css = "h2")
   
FluentWebElement headline; // this is null!
   @FindBy(css = ".someOtherClass")
   SomeOtherPageFragment someOtherPageFragment; // this is null!
}

So my first problem is with the FluentList. Following code does not work:

for (SomePageFragment somePageFragment : somePageFragments) {
   
// ClassCastException here because somePageFragments actually is a list of FluentWebElement?
   
// so how can i use my functional methods?
}

And my "SomePageFragment" also contains other fragments. How do i do that?

Thanks for your help!
Michael
Reply all
Reply to author
Forward
0 new messages