WebResponse not up to date when using client.click
laurentn Mar 20, 2008 12:50 PMHi
I'm currently trying to develop my own api to test my web site.
I'm wrapping a web page into a java class
So for example i have a basic page Page that owns a JSFClientSession and a JSFServerSession
public class Page { private JSFClientSession client; private JSFServerSession server; public Page(String pageName) { client = new JSFClientSession(pageName); server = new JSFServerSession(client); } public Page(Page page) { client=page.client; server = page.server; } public void clickOnLinkWithId(String id) { client.click(); } public MySecondPage goToSecondPage() { clientOnLinkWithId("nextPage"); return new MySecondPage(this); } public void setFormParameter(String id, String value) { client.setParameter(id, value); } } public class MySecondPage extends Page { public MySecondPage(Page page) { super(page); } public static MySecondPage getPage() { return new Page("index.jsp").goToSecondPage(); } }
and so, in my test case:
public class MyTest extends ServletTest { public void testMyTest() { MySecondPage page = MySecondPage.getPage(); page.setFormParameter("myInput", "myValue"); } }
Actually, my classes are a bit longer than the above code, by the exception is thrown in page.setFormParamter
This is because, the client.getUpdatedDOM is still on the first page, and the client is not updated when we click on the link (the link is a simple outputlink)
Only client.getWebResponse().getDOM is well updated
and server.getCurrentViewId is good also.
The exception is this one (with my own code)
java.lang.NullPointerException
at org.jboss.jsfunit.facade.JSFClientSession.setValueOnDOM(JSFClientSession.java:230)
at org.jboss.jsfunit.facade.JSFClientSession.setParameter(JSFClientSession.java:248)
at kiwi.jsfunit.api.Page.setFormParameter(Page.java:229)
at jsfunit.api.administration.AdministrationEditHelpDesks.fillAndSubmit(AdministrationEditHelpDesks.java:87)
at jsfunit.admin.hd.HelpDeskEditTest.testUploadPicture(HelpDeskEditTest.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
I hope i'm clear enough, and any help is welcome.
Thanks
Laurent