(JSFUnit) visit many url's in same session

229 Views Asked by At

I am beginner in JSFUnit and related technologies. I was wondering: is it possible to change the url without creating a new JSFSession object? I.e. I would like to simulate the situation where the user types in a new address in his/her address bar.

Additional Information

The problem is that I have many links in my facelets page, that cannot be assigned ids because they are created inside a ui:repeat element.

Workaround

Use a cookie to restore the session between different JSFSessions

1

There are 1 best solutions below

1
On BEST ANSWER

Of course.

You could have a button in your xhtml/jsp page. This button will lead to the requested page.

For example, if you have login page, and the user would like to go to test page so in your JSFUnit write:

jsfSession = new JSFSession("start.jsf");
client = jsfSession.getJSFClientSession();
client.click("Login");

and in start.jsf page have:

<h:form>
    <h:commandButton id = "Login" value="Login" action="#{loginBean.doLogin}"/>
</h:form>

where in your loginBean

public void doLogin(){
   return "test.jsf";
}   

In this way you can simulate the same session for the user.