[arquillian-issues] [JBoss JIRA] (ARQGRA-500) Navigation with URL parameters

Krassimir Valev (JIRA) issues at jboss.org
Tue Apr 11 04:54:00 EDT 2017


    [ https://issues.jboss.org/browse/ARQGRA-500?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13392046#comment-13392046 ] 

Krassimir Valev commented on ARQGRA-500:
----------------------------------------

[~vsevolodgolovanov] We implemented something similar for our project a while ago, which turned out to be very simple:
- we introduced the convention for placeholders in the Location parameter, e.g. Location("url?param={VALUE}")
- in case the placeholder had a sensible default value, which should only we overwritten in certain use cases, you can introduce a new custom annotation, e.g. DefaultLocationParam("VALUE", "1")
- with yet another custom annotation you can set a static value per test case
{code:java}
public void test(@InitialPage @LocationParam(name = "VALUE", value = "2") final PageObject page) { }
{code}
- the actual replacement happens in a custom LocationEnricher (most likely it is not possible to share the code from a legal standpoint, but hopefully this is enough of a pointer for you)
{code:java}
public class MyLocationEnricher implements org.jboss.arquillian.test.spi.TestEnricher {

 @Override
    public Object[] resolve(final Method method) {
// from the method you can get all sorts of information that you need - the PageObject class, annotations, the test class and so on
// you can also take a look at the org.jboss.arquillian.graphene.location.LocationEnricher class so see the default behaviour
    }
}
{code}

You can then override the default behaviour with your own:
{code:java}
public class MyGrapheneExtension implements org.jboss.arquillian.core.spi.LoadableExtension {
    @Override
    public void register(final ExtensionBuilder builder) {
        builder.override(TestEnricher.class, LocationEnricher.class, MyLocationEnricher.class);
    }
}
{code}

and the last step is to register your extension with the Arquillian runtime, by creating the file 'org.jboss.arquillian.core.spi.LoadableExtension' in the folder 'META-INF/services'. The file should contain the fully qualified path to your extension, e.g. com.company.graphene.MyGrapheneExtension


> Navigation with URL parameters
> ------------------------------
>
>                 Key: ARQGRA-500
>                 URL: https://issues.jboss.org/browse/ARQGRA-500
>             Project: Arquillian Graphene
>          Issue Type: Feature Request
>            Reporter: Vsevolod Golovanov
>
> I need to add a dynamic URL parameter to a location of a page before navigating to it.
> I don't want to use Selenium's navigation, because I would then need to reinvent/shoehorn Graphene's location deciding.
> A special landing page would be a pretty ugly workaround.
> I get that it's not possible with annotations. But at least support this with Graphene.goTo methods.
> Actually it may be possible with annotations, if you could supply some provider class? E.g. {{\@Location(value = "MyView.xhtml", parameterProvider = MyParameterProvider.class)}}.



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the arquillian-issues mailing list