mouellet / vaadin-testbench-support

Support library to enable the use of the PageObject pattern and Selenium's PageFactory with Vaadin TestBench 4
0 stars 0 forks source link

List<ButtonElement> results in ClassCastException #1

Open kameamea opened 8 years ago

kameamea commented 8 years ago

When I'm using this nice addon for lists of elements I'm restricted to WebElements/TestBenchElements: With any other element like ButtonElement, for example in this code:

@FindByVaadin()
private List<ButtonElement> buttons;

ButtonElement b = buttons.get(0);

results in

java.lang.ClassCastException: com.vaadin.testbench.TestBenchElement_$$_jvst7f2_1 cannot be cast to com.vaadin.testbench.elements.ButtonElement

If I replace ButtonElement in the above code with TestBenchElement everywhere there is no exception thrown. But I don't have access to the specialized types then as well.

mouellet commented 8 years ago

Since I've never came across the need for this feature while working with the PageObject pattern, I haven't implemented any specialized element list locator. That's why the Selenium default is applied and it only works with WebElements/TestBenchElements.

I think this could be done by replacing the LocatingElementListHandler of the TestBenchElementDecorator.proxyForListLocator method by one that would create the specialized TestBenchElement...