[
https://issues.jboss.org/browse/ARQGRA-326?page=com.atlassian.jira.plugin...
]
Szymek Pindelski commented on ARQGRA-326:
-----------------------------------------
hello there, are there any plans to get round to fixing this issue ?
It's simetimes handy to use a nested class as a page fragment - for example when a
specific section of a web page may occur once or multiple times -- as with JSF
<repeat> tag? -- and unlike a widget-type page fragment, the section is not
reusable (it doesn't make sense to reference it from other page objects / page
fragments across your test suite).
With and outer class reference you can for instance call your custom assertOnPage() method
to ensure you're at the right web page or reuse your enclosing page object's drone
reference.
Support for full initialization of outer class instance of a page
fragment declared as inner class
--------------------------------------------------------------------------------------------------
Key: ARQGRA-326
URL:
https://issues.jboss.org/browse/ARQGRA-326
Project: Arquillian Graphene
Issue Type: Feature Request
Components: core
Affects Versions: 2.0.0.Alpha4
Reporter: Juraj Húska
Priority: Minor
Fix For: 2.0-Tracking
If a Page Fragment is declared as inner class, then it can not access the fields of its
outer class, as their are not inicialized by Graphene Enrichers, thus are {{null}}.
The possible ugly workaround for such initialization can be:
{code}
if (pageFragment.getClass().getEnclosingClass() != null) {
Field field = pageFragment.getClass().getDeclaredField("this$0");
field.setAccessible(true);
Object outer = field.get(pageFragment);
enrichRecursively(root, outer);
}
{code}
It should be placed in some utility class, so it can be easily unit tested.
There is one drawback of this method and that is, the outer class can not contain
injection point for the inner class, otherwise it will cycle. The inner class can be
obtained only dynamically via {{Graphene.createPageFragment}}.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)